← 返回 meta 的题目列表Subarray Sum Equals K (Variant)
类型:online_judge
Given an integer array nums and an integer k, return the number of contiguous subarrays whose sum equals k.
Notes:
Subarray must be contiguous.
The array may contain negative numbers.
Constraints
1 <= len(nums) <= 2e5
-1e4 <= nums[i] <= 1e4
-1e9 <= k <= 1e9
Examples
Input: nums = [1,1,1], k = 2 Output: 2
Input: nums = [1,2,3], k = 3 Output: 2
Example
Input
3
1 1 1
2
Output
2