using 3 pointers…k…j…i

sum between k to i will be <=C and from j to i will be <B, then ans+= j-k

Implementation:-

int Solution::numRange(vector &A, int B, int C) {

int sum=0,j=0,k=0,cnt=0,n=A.size();

for(int i=0;i<A.size();i++){

sum+= A[i];

while(sum>C and k<n){

sum-= A[k]; k++;

}

j = k;

int temp = sum;

while(temp>=B and j<n){

temp-= A[j];

j++;

}

cnt+= j-k;

}

return cnt;

}