[Java] Sliding window / Two Pointers O(n)
\nclass Solution {\n    public int numberOfSubarrays(int[] nums, int k) {\n        int start = 0, end = 0, len = nums.length;\n        int count = 0, oddCount =
```\nclass Solution {\n    public int numberOfSubarrays(int[] nums, int k) {\n        int start = 0, end = 0, len = nums.length;\n        int count = 0, oddCount = 0, evenCount = 0;\n        \n        while(end < len){\n            \n            while(end < len && oddCount < k){\n                if(nums[end++] % 2 != 0)  ++oddCount;\n            }\n            \n           evenCount = 1;\n           while(end < len && nums[end] % 2 == 0){\n                ++evenCount;\n                ++end;\n           }\n           \n           while(start < len && oddCount == k){\n                count += evenCount;\n                if(nums[start++] % 2 != 0) --oddCount;\n           }\n        }\n        \n        return count;\n    }\n}\n```
['Two Pointers', 'Sliding Window', 'Java']