Untitled
unknown
plain_text
3 years ago
499 B
3
Indexable
class Solution {
public:
int numOfSubarrays(vector<int>& arr, int k, int threshold) {
int i=0,j=0,sum=0,count=0;
while(j<arr.size())
{
if( (j-i+1) == k )
{
if( (sum/2) >= threshold)
{
count++;
}
sum -= arr[i];
i++;
j++;
}
else
{
j++;
}
sum += arr[j];
}
return count;
}
};Editor is loading...