Problem
Given a list of integers nums and a number target, find the two different positions whose values add up to target. Return their indices as a list in increasing order.
Example 1
- Input
- nums = [2, 7, 11, 15], target = 9
- Output
- [0, 1]
- Why
- 2 + 7
Example 2
- Input
- nums = [3, 2, 4], target = 6
- Output
- [1, 2]
- Why
- 2 + 4
Example 3
- Input
- nums = [3, 3], target = 6
- Output
- [0, 1]
You may not use the same index twice.
Constraints
2 <= nums.length <= 10^4-10^9 <= nums[i] <= 10^9Exactly one valid answer exists.