Easy sliding window solution with O(N) time  complexity
Intuition\r\n Describe your first thoughts on how to solve this problem. \r\nThis Problem is talking about subarrays so the first thought that should come in yo
# Intuition\r\n<!-- Describe your first thoughts on how to solve this problem. -->\r\nThis Problem is talking about subarrays so the first thought that should come in your mind -> sliding window\r\n# Approach\r\n<!-- Describe your approach to solving the problem. -->\r\n1. first take two pointer on index 0\r\n2. now the second pointer will diverse from start , until the number of odds are not equals to k\r\n3. when the number of equal to k start increasing the second pointer until it eliminates the odd from start and makes number of odds less than k, along with it increase the prefix \r\n4.add the prefix in count until the next odd are not found \r\n5. Repeat the steps again\r\n# Complexity\r\n- Time complexity:\r\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\r\nO(n)\r\n- Space complexity:\r\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\r\nO(1)\r\n# Code\r\n```\r\n/**\r\n * @param {number[]} nums\r\n * @param {number} k\r\n * @return {number}\r\n */\r\nvar numberOfSubarrays = function(nums, k) {\r\n    let odds=0;\r\n    let count=0;\r\n    let prefix=0\r\n\r\n    let i=0;\r\n\r\n    for(let j=0;j<nums.length;j++){\r\n        if(nums[j]%2!=0){ \r\n            odds+=1\r\n            prefix=0\r\n            }\r\n\r\n        while(odds==k && i<=j){\r\n         if(nums[i]%2!=0)   odds-=1\r\n            i++\r\n           prefix++\r\n      \r\n        }\r\n       \r\n   count+=prefix\r\n\r\n    }\r\n    return count\r\n};\r\n```
['JavaScript']