C++ || 3 APPROACHES || SOLUTION
\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        int i=0;\n        int j=0;\n        int count=0;\n        int result
```\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        int i=0;\n        int j=0;\n        int count=0;\n        int result=0;\n        int first_occur=0;\n        vector<int>occur(nums.size(),0);\n        int index=0;\n        int current=0;\n        // Variable window size problem\n        while(j<nums.size())\n        {\n            // Do pre-calculation\n            if(nums[j]%2!=0)\n            {count++;\n             occur[index++]=j;}\n            // Play with condition\n            if(count<k)\n                j++;\n            else\n            {\n              while(count>k)\n              {\n                  // remove calculation for i\n                  if(nums[i]%2!=0)\n                  {count--;current++;}\n                  i++;\n              }\n                \n                // Store result\n                result+=occur[current]+1-i;\n                j++;\n            }\n            \n            \n        }\n        return result;\n    }\n};\n\nTime Complexity: O(n)\nSpace Complexity: O(n)\n```\n\n```\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        // Replace all odd with 1 and even with 0\n        for(auto &num:nums)\n            if(num%2)\n                num=1;\n            else\n                num=0;\n        \n        // Now find the subarray with sum at most k and k-1\n        return atMost(nums,k)-atMost(nums,k-1);\n    }\n    int atMost(vector<int>&nums,int k)\n    {\n        int i=0;\n        int j=0;\n        int result=0;\n        int sum=0;\n        // Variable size window problem\n        while(j<nums.size())\n        {\n            // Do pre-calculation\n            sum+=nums[j];\n            \n           \n                while(sum>k)\n                {\n                    // remove calculation for i\n                    sum-=nums[i];\n                    i++;\n                }\n                // store result\n                result+=j-i+1;\n                j++;\n            \n        }\n        return result;\n    }\n};\n\nTime Complexity: O(3*n)\nSpace Complexity: O(1)\n```\n\n```\nclass Solution {\npublic:\n    int numberOfSubarrays(vector<int>& nums, int k) {\n        unordered_map<int,int>mp;\n        // Replace odd with 1 and even with 0\n        for(auto &num:nums)\n            if(num%2)\n                num=1;\n            else \n                num=0;\n        mp[0]=1;\n        int sum=0;\n        int count=0;\n        for(auto num:nums)\n        {\n            sum+=num;\n            count+=mp[sum-k];\n            mp[sum]++;\n        }\n        return count;\n    }\n    \n};\n\nTime Complexity: O(2*n)\nSpace Complexity: O(n)\n```\n\n***PLEASE UPVOTE IF YOU FIND IT A LITTLE BIT HELPFUL, MEANS A LOT ;)***
['C', 'Sliding Window', 'Prefix Sum', 'C++']