leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1764.cpp (493B)


      1 class Solution {
      2   public:
      3     bool canChoose(const vector<vector<int>> &groups, const vector<int> &nums) const {
      4         const int n = size(groups);
      5         int group = 0, crnt = 0, start = 0;
      6         for (int i = 0; i < size(nums) && group < n; i++) {
      7             if (nums[i] != groups[group][crnt])
      8                 crnt = 0, i = start, start++;
      9             else if (++crnt == size(groups[group]))
     10                 group++, crnt = 0, start = i;
     11         }
     12 
     13         return group == n;
     14     }
     15 };