This O(n^2) solution works pretty well


#1

public class Solution {
public int numRange(ArrayList A, int B, int C) {
int count = 0;
int sum = 0;
for(int i=0;i<A.size();i++){
sum=0;
for(int j=i;j<A.size();j++){
sum += A.get(j);
if(sum>=B && sum<=C)
count +=1;
if(sum > C)
break;
}
}
return count;
}
}