Dont fall into the Two pointer/Sliding Window trap
This question is a direct variation of running subarray sum. This approach is simple and highly intuitive compared to sliding window and 2 pointers.\n\nThe map 
This question is a direct variation of running subarray sum. This approach is simple and highly intuitive compared to sliding window and 2 pointers.\n\nThe map is storing {key, val} == {num of odds in subarray, num of subarray with these many odds that have been encountered till now}\n\nKey insight --> The map only stores subarrays starting from the first element of the array. All the other subarrays are are taken care of using the below logic.\n\nSay we want to find all 2 odd num size subarrays. And now we are at a point where we have 5 odd nums with us, we want to look into the map for all the subarrays with 3 odd nums that have been encountered yet(map). This is because if we have a 5 odd num subarray and we know of previous 3 odd num subarrays. All of those 3 odd num sized subarrays when removed out of the 5 sized subarray will give us 2 odd num sized subarrays. Hence add it to result.\n\n----------------------\n```\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        \n        int res = 0; int cnt = 0;\n        unordered_map<int, int> mp; mp[0] = 1;\n        \n        for(auto n : nums) {\n            \n            if(n % 2) cnt++;\n            res += mp[cnt - k];\n            mp[cnt]++;\n        }\n        \n        return res;\n    }\n```
[]