


If arr = [3,2,3], and k = 1
then there are 4 subarrays with 1 odd elements:
[3], [3,2], [2,3] & [3].
The first line contains single space-separated two integers 'N' and 'k'.
The second line contains 'N' space-separated integers, denoting the elements of array 'arr'.
The output contains the number of distinct subarrays with 'k' odd elements.
You do not need to print anything, it has already been taken care of. Just implement the given function.
The idea is to maintain a count of odd numbers encountered so far and use a hashmap to keep track of frequency of different counts. This approach is similar to the approach used in finding subarray of sum k.
Algorithm:
function distinctSubKOdds(arr, k):
To count the distinct subarrays with exactly 'k' odd elements, we can use the sliding window technique. The idea is to maintain a window that contains at most 'k' odd elements. We will use two pointers, 'i' and 'j', to define the window. The right pointer 'i' will expand the window by moving forward, and the left pointer 'j' will contract the window when the count of odd elements in the window exceeds 'k'.
distinctSubKOdds(arr, k):