Simple Pattern Tech


#1
int Solution::solve(vector<int> &A, int B) {
int n=A.size();
int i=0;
int j=0;
int count=0;
int sum=0;
while(j<n)
{
    sum+=A[j];
    while(sum>=B)
    {
        sum-=A[i++];
    }
    count+=(j-i+1);
    j++;
}
return count;

}