Two PointersMedium
Two Sum II - Input Array Is Sorted
numbers is sorted from small to large. Return the 1-based positions [i, j] with i < j of the two numbers that add up to target. There is exactly one answer. Use O(1) extra space.
Example 1numbers = [1, 3, 4, 6, 9], target = 13 → [3, 5]4 + 9 = 13, at positions 3 and 5.
Example 2numbers = [-2, 0, 5], target = 3 → [1, 3]
2 ≤ n ≤ 3·10⁴ · sorted · one answer