[Java/Python 3] 1 pass Sliding Window O(n) time O(1) space w/ brief explanation.
Whenever the count of odd numbers reach k, for each high boundary of the sliding window, we have indexOfLeftMostOddInWin - lowBound options for the low boundary
1. Whenever the count of odd numbers reach `k`, for each high boundary of the sliding window, we have `indexOfLeftMostOddInWin - lowBound` options for the low boundary, where `indexOfLeftMostOddInWin` is the index of the leftmost odd number within the window, and `lowBound` is the index of the low boundary exclusively;\n2. Whenever the count of odd numbers more than `k`, shrink the low boundary so that the count back to `k`;\n```java\n    public int numberOfSubarrays(int[] nums, int k) {\n        int ans = 0, indexOfLeftMostOddInWin = 0, lowBound = -1;\n        for (int num : nums) {\n            k -= num % 2;\n            if (nums[indexOfLeftMostOddInWin] % 2 == 0) // move to the index of first odd.\n                ++indexOfLeftMostOddInWin;\n            if (k < 0) { // more than k odds in window, need to shrink from low bound.\n                lowBound = indexOfLeftMostOddInWin; // update the low bound value.\n            }\n            while (k < 0) {\n                k += nums[++indexOfLeftMostOddInWin] % 2; // move to the index of next odd.\n            }\n            if (k == 0) { // accumulated k odd numbers in window.\n                ans += indexOfLeftMostOddInWin - lowBound; // update result.\n            }\n        }\n        return ans;\n    }\n```\n```python\n    def numberOfSubarrays(self, nums: List[int], k: int) -> int:\n        low_bound, index_of_left_most_odd_in_win, ans = -1, 0, 0\n        for num in nums:\n            k -= num % 2\n            if nums[index_of_left_most_odd_in_win] % 2 == 0:\n                index_of_left_most_odd_in_win += 1\n            if k < 0:\n                low_bound = index_of_left_most_odd_in_win\n            while k < 0:    \n                index_of_left_most_odd_in_win += 1\n                k += nums[index_of_left_most_odd_in_win] % 2\n            if k == 0:\n                ans += index_of_left_most_odd_in_win - low_bound\n        return ans\n```
[]