560. Subarray Sum Equals K

Practice Subarray Sum Equals K for free on NudgeCode: Medium, Array & Hash Table pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Count how many contiguous, non-empty subarrays of nums add up to exactly k. Values can be negative, so a sliding window won't work.

Example

nums = [1,2,3], k = 3  ->  2   ([1,2] and [3])

Constraints