Easy Solution Using Sliding Window!
\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        int n=nums.size();\n        int odd=0,l=0,res=0;\n        for(int r=
```\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        int n=nums.size();\n        int odd=0,l=0,res=0;\n        for(int r=0;r<n;r++)\n        {\n            if(nums[r]%2==1)\n                odd++;\n            while(l<r && odd>k)\n            {\n                if(nums[l]%2==1)\n                    odd--;\n                l++;\n            }\n            if(odd==k)\n                res++;\n            for(int i=l; odd==k && i<r && nums[i]%2==0;i++)\n                res++;\n        }\n        return res;\n    }\n};\n```\nA problem similar to this:\nhttps://leetcode.com/problems/binary-subarrays-with-sum/description/\nsolution:\nhttps://leetcode.com/problems/binary-subarrays-with-sum/discuss/426284/Easy-Solution-Using-Sliding-Window!
[]