Two Sum
Problem Return the indices of the two numbers in an array that sum to a given goal. Exactly one valid pair exists.
Input / Output
- Input: integer array
nums, integergoal. - Output: the pair of indices [i, j] with nums[i] + nums[j] == goal.
Constraints
- 2 <= n <= 10^4; exactly one solution; an element may not be reused.
Example
- [1,3,6,7,9], goal = 10 → [1,3] (3 + 7 = 10).
added …