🤗👀JAVA | VERY EASY
Intuition\r\n Describe your first thoughts on how to solve this problem. \r\n\r\n# Approach\r\n Describe your approach to solving the problem. \r\n\r\n# Complex
# Intuition\r\n<!-- Describe your first thoughts on how to solve this problem. -->\r\n\r\n# Approach\r\n<!-- Describe your approach to solving the problem. -->\r\n\r\n# Complexity\r\n- Time complexity:\r\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\r\n\r\n- Space complexity:\r\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\r\n\r\n# Code\r\n```\r\nclass Solution {\r\n    public int numberOfSubarrays(int[] nums, int k) {\r\n        int i=0;\r\n        int j=0;\r\n        int oddCount=0;\r\n        int ans=0;\r\n         int count=0;\r\n\r\n        while(j<nums.length){\r\n            \r\n            if(nums[j]%2!=0){\r\n                oddCount++;\r\n                ans=0;\r\n            }\r\n            \r\n            while(oddCount==k){\r\n                ans++;\r\n                if(nums[i]%2!=0){  \r\n                    oddCount--;\r\n    \r\n                }\r\n                i++;\r\n            }\r\n            count+=ans;\r\n            j++;\r\n        }\r\n        return count;\r\n    }\r\n}\r\n```
['Java']