Simplest solution using two pointer


#1

int Solution::solve(vector &A, int B) {
int sum=0,temp=0,c=0;
for(int i=0;i<A.size();i++)
{sum=0;
for(int j=i;j<A.size();j++)
{sum+=A[j];
if(sum<B)
c++;
else
break;}
}
return c;
}