Count Subarrays With Score Less Than K LeetCode solution in JavaScript

1
var countSubarrays = function (nums, k) {
2
let curentRunningSum = 0,
3
result = 0,
4
windowEnd = 0,
5
windowStart = 0;
6
while (windowEnd < nums.length) {
7
curentRunningSum += nums[windowEnd];
8
while (curentRunningSum * (windowEnd - windowStart + 1) >= k)
9
curentRunningSum -= nums[windowStart++];
10
result += windowEnd - windowStart + 1;
11
windowEnd++;
12
}
13
return result;
14
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0