deliveries[i] is the net change in packages at hour i (can be negative for returns). Count the contiguous windows of hours whose total is exactly k.
Signature
countWindows(deliveries: int[], k: int) → intExample 1
deliveries = [1,1,1]
k = 2
output = 2
[1,1] twice
Example 2
deliveries = [1,2,3]
k = 3
output = 2
[1,2] and [3]
Constraints
1 ≤ n ≤ 2·10^4-1000 ≤ deliveries[i] ≤ 1000-10^7 ≤ k ≤ 10^7
⌘/Ctrl + Enter runs examples
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).