Problem
You are given a list numbers that is sorted in ascending order and a number target. Find the two different positions whose values add up to target and return their 0-based indices in increasing order.
Example 1
- Input
- numbers = [2, 7, 11, 15], target = 9
- Output
- [0, 1]
Example 2
- Input
- numbers = [2, 3, 4], target = 6
- Output
- [0, 2]
Example 3
- Input
- numbers = [-1, 0], target = -1
- Output
- [0, 1]
Constraints
2 <= numbers.length <= 3 * 10^4-1000 <= numbers[i] <= 1000-1000 <= target <= 1000Exactly one valid pair exists.Use only O(1) extra space.