Two Sum / Hashmap
Problem
Return the indices of the two numbers in the array that sum to a given target. Exactly one valid pair is guaranteed.
Example
[2,7,11,15], target 9 -> [0,1]
Constraints
- 2 ≤ n ≤ 10^4
added …
Return the indices of the two numbers in the array that sum to a given target. Exactly one valid pair is guaranteed.
[2,7,11,15], target 9 -> [0,1]