java solution
\nclass Solution {\n    public int numberOfSubarrays(int[] nums, int k) {\n        int i = 0;\n        int j = 0;\n        int odd = 0;\n        int result = 0;
```\nclass Solution {\n    public int numberOfSubarrays(int[] nums, int k) {\n        int i = 0;\n        int j = 0;\n        int odd = 0;\n        int result = 0;\n        int temp = 0;\n        \n        \n        /* \n            Approach : two pointer + sliding window technique\n            \n            step 1 : we have fix i and moving j until our count of odd numbers == k\n            step 2 : when(odd == count) we are counting every possible subarray by reducing the size of subarray from i\n            \n        why temp?\n        from reducing the size of subarray we will count all the possible subarray from between i and j\n        but when i encounter a odd element the odd count will reduce and that while will stop executing\n        \n        now there are two possible cases\n        1.The leftover elements have a odd number\n        2.The leftover elements do not have any odd number\n        \n        1. if our leftover elements have a odd number \n                then we cannot include our old possible subarrays into new possible subarrays because now new window for having odd == k is formed\n                that\'s why temp = 0;\n                \n        2. if out leftover elements do not have any odd element left\n            then our leftover elements must also take in consideration becuase they will also contribute in forming subarrays\n        */\n        while(j< nums.length){\n            if(nums[j]%2 != 0)\n            {\n                odd++;\n                //if leftover elements have odd element then new window is formed so we set temp = 0;\n                temp = 0;\n            }\n            while(odd ==k){\n                temp++;\n                if(nums[i] %2 != 0)\n                    odd--;\n                i++;\n             }\n          //if no leftover elements is odd, each element will part in forming subarray\n        //so include them\n            result += temp;\n            j++;\n            \n        }\n        return result;\n    }\n}\n```
['Sliding Window', 'Java']