Given an array of integers and a number target, find a continous subarray whose sum is equal to target.
Return the start and end indices denoting this subarray. If there are multiple solutions, you can return any of them.
Example:
Input: nums = [1, 1, 5, 2, 1, 3, 10, 2, 1], k = 21
Output: [2, 6]
Explanation: 5 + 2 + 1 + 3 + 10 = 21
Notes:
1. The array can consist of positive and negative numbers.
2. Your algorithm should run in O(n) time and use O(n) extra space.
Video Solution - Live Mock Coding Interview:
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check