What would be the Time Complexity for this Solution (CPP)?


#1
int Solution::numRange(vector<int> &A, int B, int C) {
int srt = 0, end = 0, sum = 0, count = 0;
while(end < A.size()){
    sum += A[end];
    while(sum > C){
        sum -= A[srt];
        srt++;
    }
    int index = srt, temp = sum;
    while(temp >= B && temp <= C && end >= srt){
        count++;
        temp -= A[index];
        index++;
    }
    end++;
}
return count;

}


#2

How come the return value is 6 for following input?

21 80 97 78 45 23 38 38 93 83 16 91 69 18 82 60 50 61 70 15 6 52 90
99
269