A beautiful subarray is defined as an array of length having a specific number of odd elements. Given an array of integers and a number of odd elements that constitutes beauty, create as many distinct beautiful subarrays as possible. Distinct means the arrys dont share identical starting and ending indices, though they may share one of the two.
For example, given the array [1,2,3,4,5] and a beautiful number 2, the following beautiful subarrays can be formed.
[1,2,3]
[1,2,3,4]
[2,3,4,5]
[3,4,5]
output: 4
More Example
[2,5,4,9] , 2
subarrays
[5,4,9]
[2,5,4,9]
output:2