You are given an integer array numbers
that is already sorted in ascending order.
Find two numbers in the array such that their sum equals a given number target
.
Return the answer as a list of two indexes [i, j]
.
0 <= i < j < numbers.length
.Example 1
numbers = [1, 2, 4, 6, 10], target = 8
Output: [1, 3]
Explanation: 2 + 6 = 8
Example 2
numbers = [2, 3, 4], target = 6
Output: [0, 2]
Explanation: 2 + 4 = 6
Example 3
numbers = [-1, 0], target = -1
Output: [0, 1]
Explanation: -1 + 0 = -1