← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Meta/Leetcode 560. Subarray Sum Equals K
CodingMust
Given an array of integers and a target sum value, determine how many contiguous subarrays within the array sum exactly to the target value.
A subarray is a continuous portion of the array. For example, in the array [1, 2, 3], valid subarrays include [1], [2], [3], [1, 2], [2, 3], and [1, 2, 3].
kExample 1:
Input: nums = [1, 2, 3, 4], k = 5 Output: 2 Explanation: The subarrays [2, 3] and [1, 4] both sum to 5
Example 2:
` Input: nums = [1, -1, 1, -1, 1], k = 0 Output: 4 Explanation: Multiple subarrays sum to 0:
Example 3:
Input: nums = [3, 5, 2, 7], k = 7 Output: 2 Explanation: Subarrays [7] (single element) and [5, 2] both sum to 7