Python3 Solution
\n\nclass Solution:\n    def numberOfSubarrays(self, nums: List[int], k: int) -> int:\n        n=len(nums)\n        i=0\n        count=0\n        ans=0\n       
\n```\nclass Solution:\n    def numberOfSubarrays(self, nums: List[int], k: int) -> int:\n        n=len(nums)\n        i=0\n        count=0\n        ans=0\n        for j in range(n):\n            if nums[j] & 1:\n                k-=1\n                count=0\n            while k==0:\n                k+= nums[i] & 1\n                i+=1\n                count+=1\n            ans+=count\n        return ans            \n```
['Python', 'Python3']