Count Subarrays With Score Less Than K LeetCode solution in Java

1
class Solution {
2
public long countSubarrays(int[] nums, long k) {
3
int i = 0;
4
int j = 0;
5
long max = 0;
6
long operation = 0;
7

8
while (j < nums.length) {
9
operation += nums[j];
10
while (operation * (j - i + 1) >= k) {
11
operation -= nums[i];
12
i++;
13
}
14
max += j - i + 1;
15
j++;
16
}
17
return max;
18
}
19
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0