int Solution::solve(vector &A, int B) {

int n=A.size();

int pref[n]={0};

```
int cntodd=0;
int ans=0;
for(int i=0;i<n;i++)
{
pref[cntodd]++;
if(A[i]%2) cntodd++;
if(cntodd>=B) ans+=pref[cntodd-B];
}
return ans;
}
```

The following code gives correct answer on Trivial Tests, but fails on the test case

A : [ 5, 5, 1, 3, 1 ]

B : 0

In custom input it results in 0, which is the expected output, but on submission it’s giving random answers as output. Kindly look at this.