The problem. Given an array arr of integers, return how many subarrays (runs of consecutive elements) add up to 0. Overlapping subarrays count separately.
arr = [15, -2, 2, -8, 1, 7, 10, 23] -> 3
arr = [0, 0, 5, 5, 0, 0] -> 6 ([0], [0], [0, 0], and the same three on the right)
arr = [1, 2, 3] -> 0Members only · free account
The rest of this lesson, with 7 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson