Easy solution
Intuition\r\n Describe your first thoughts on how to solve this problem. \r\nConsider the window with k prime numbers, the number of evens on either side are va
# Intuition\r\n<!-- Describe your first thoughts on how to solve this problem. -->\r\nConsider the window with k prime numbers, the number of evens on either side are variables, Maintain evens on left and right of every odd numbers, ans is sum of (evens on left of first number + 1 * evens on right of last number + 1). \r\n\r\n![lc.jpg](https://assets.leetcode.com/users/images/28f2ce74-3258-44e1-b592-a785dd278d4c_1688292738.8399723.jpeg)\r\n\r\n\r\n# Approach\r\n<!-- Describe your approach to solving the problem. -->\r\nStore the evens on left of every number in a vector and evens on the right of last element in last. Slide a window of size k , add (s[i]+1 * s[i+k]+1 ) to the sum. \r\n\r\n# Complexity\r\n- Time complexity:O(N)\r\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\r\n\r\n- Space complexity:O(N)\r\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\r\n\r\nPlease upvote if you find it helpful \r\n\r\n# Code\r\n```\r\nclass Solution {\r\npublic:\r\n    int numberOfSubarrays(vector<int>& nums, int k) {\r\n        // Vector to store the evens between odd numbers\r\n        vector<int> t;\r\n        int temp = 0, ans = 0; \r\n        // Store Evens between odds\r\n        for(int i=0; i<nums.size(); i++) {\r\n            if(nums[i]%2 == 0) temp++; \r\n            else {\r\n                t.push_back(temp); temp = 0; \r\n            }\r\n        }\r\n        t.push_back(temp); \r\n        int ind = 0; \r\n        //sliding window to count number of subarrays\r\n        while(ind + k < t.size()){ ans += (t[ind]+1) * (t[ind+k]+1); ind++; }\r\n\r\n        return ans; \r\n\r\n    }\r\n};\r\n```
['Sliding Window', 'C++']