simple and easy || C++ and Python || solution 😍❤️‍🔥
if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Python Code\n\nclass Solution:\n    def numberOfSubarrays(self, nums: List[int], k: int) -> int:\n    
# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Python Code\n```\nclass Solution:\n    def numberOfSubarrays(self, nums: List[int], k: int) -> int:\n        pref_count = defaultdict(int)\n        pref_count[0] = 1\n        odd_count, ans = 0, 0\n        for num in nums:\n            odd_count += num%2\n            if odd_count - k in pref_count:\n                ans += pref_count[odd_count - k]\n            pref_count[odd_count] += 1\n        return ans\n```\n# C++ Code\n```\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) \n    {\n        int cnt = 0, ans = 0, odd;\n        unordered_map<int,int>mp;\n        mp[0] = 1;\n        for(auto val:nums)\n        {\n            if(val%2) cnt++;\n            odd = cnt - k;\n            if(mp.find(odd) != mp.end())\n                ans += mp[odd];\n            mp[cnt]++;\n        }\n        return ans;\n    }\n};\n```
['Array', 'Hash Table', 'Math', 'Sliding Window', 'C++', 'Python3']