Subarray Sum Equals K

Medium
ArrayHash TablePrefix SumGoogleAmazon
Given an integer array and target k, print the number of contiguous subarrays whose sum equals k. Input format: - First line: n k - Second line: n integers

Constraints

1 <= n <= 10^5
-10^9 <= nums[i], k <= 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit