O(N) Solution by counting less than K sum subarrays


#1

A better way of doing it in O(N) is just find the count of subarrays less than C and count of subarrays less than B-1, and then difference of these two counts is simply your ans.
How to find count of subarrays with sum less than K in O(N)? Use two pointers approach.