The problem. Given an array of integers nums and an integer k, return the number of subarrays whose elements add up to exactly k. The numbers may be negative.
nums = [1, 1, 1], k = 2 -> 2 ([1, 1] twice)
nums = [1, 2, 3], k = 3 -> 2 ([1, 2] and [3])
nums = [3, 4, 7, 2, -3, 1, 4, 2], k = 7 -> 4Free account
Sign up to read the rest of this lesson: 7 more sections, 2 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come