Write solve(nums, target) that returns the indices [i, j] (i < j) of the two numbers in nums that add up to target. Assume exactly one solution exists.
Two Sum Indices
Examples
- solve([2,7,11,15], 9) → [0,1]
- solve([3,2,4], 6) → [1,2]
Write solve(nums, target) that returns the indices [i, j] (i < j) of the two numbers in nums that add up to target. Assume exactly one solution exists.
Examples