JAVA Easy Consise O(n)
\nclass Solution {\n    public int numberOfSubarrays(int[] nums, int k) {\n        return count(nums,k) - count(nums,k-1); \n\t\t// number of subarrays with k o
```\nclass Solution {\n    public int numberOfSubarrays(int[] nums, int k) {\n        return count(nums,k) - count(nums,k-1); \n\t\t// number of subarrays with k odd integers  = number of subarrays with atmost k odd integer -  number of subarrays with atmost k-1 odd integers\n    }\n    public int count(int[] nums,int k){\n        int res = 0,start = 0,end = 0, count =0;\n        while(end < nums.length){\n            if(nums[end] % 2 == 1) count++;\n            while(start <= end && count > k){\n                if(nums[start] % 2 == 1) count--;\n                start++;\n            }\n            res += (end - start + 1);\n            end++;\n        }\n        return res;\n    }\n}\n```
['Java']