[C++] O(1) Space
\nclass Solution {\npublic:\n    \n    int atmost (vector<int>& arr, int k){\n        if(arr.size()==0)\n            return 0 ;\n        int ans = 0;\n        i
```\nclass Solution {\npublic:\n    \n    int atmost (vector<int>& arr, int k){\n        if(arr.size()==0)\n            return 0 ;\n        int ans = 0;\n        int j= 0;\n        int count = 0;\n        for ( int i =0;i<arr.size();i++){\n            if(arr[i]&1){\n                count++;\n            }\n            while(count>k){\n                if(arr[j]&1)\n                    count--;\n                j++;\n            }\n            ans+=i-j+1;\n        }\n        return ans;\n    }\n    \n    int numberOfSubarrays(vector<int>& v, int k) {\n        return atmost(v,k)-atmost(v,k-1);\n    }\n};\n```
['C', 'Sliding Window', 'C++']