C++ Sliding window O(N)
\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        int i(0), ans(0), c(0);\n        for (int j = 0; j < nums.size(); ++
```\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        int i(0), ans(0), c(0);\n        for (int j = 0; j < nums.size(); ++j) {\n            if (nums[j] % 2) c++;\n            if (c == k) {\n                int t1(i), t2(j);\n                while (nums[i++] % 2 == 0) {};\n                while (++j < nums.size() && nums[j] % 2 == 0) {}\n                ans += (i - t1) * ((j--) - t2);\n                c--;\n            }\n        }\n        \n        return ans;\n    }\n};\n```
[]