| leetcodeSolution to some Leetcode problems written in C++ | 
| git clone git://git.dimitrijedobrota.com/leetcode.git | 
| Log | Files | Refs | README | LICENSE | 
3034.cpp (614B)
    0 class Solution {
              1   public:
              2     int countMatchingSubarrays(const vector<int> &nums, const vector<int> &pattern) const {
              3         const int n = size(nums), m = size(pattern);
              4         int res = 0;
          
              6         for (int i = 1; i <= n - m; i++) {
              7             for (int j = 0; j < m; j++) {
              8                 if (pattern[j] == -1 && nums[i + j] >= nums[i + j - 1]) goto next;
              9                 if (pattern[j] == 0 && nums[i + j] != nums[i + j - 1]) goto next;
             10                 if (pattern[j] == 1 && nums[i + j] <= nums[i + j - 1]) goto next;
             11             }
             12             res++;
             13         next:;
             14         }
          
             16         return res;
             17     }
             18 };