Used prefix sum array but failing for larger test cases. please help


#1

l,r,sumS,count=0,1,A[0],0
while l<len(A) and r<len(A):
sumS+=A[r]
A[r]=sumS
while A[r]-A[l]>C:
l+=1
k=l
while A[r]-A[k]<=C and A[r]-A[k]>=B:
count+=1
k+=1
r+=1
return count