Given nums and k, return the total number of contiguous subarrays whose sum equals k.
nums
k
nums = [1,1,1], k = 2
2
nums = [1,2,3], k = 3
Why
[1,2] and [3]
1 <= nums.length <= 2 * 10^4 -1000 <= nums[i] <= 1000 -10^7 <= k <= 10^7
Topics
Implement subarraySum in the editor and return the answer — printing it is never graded.
subarraySum
Problem 87 of 1146 in the arena