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)


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