Two Sum II - Implementation

Here is the implementation:

function twoSum(numbers, target):
    left = 0
    right = numbers.length - 1

    while left < right:
        sum = numbers[left] + numbers[right]

        if sum == target:
            return [left + 1, right + 1]
        else if sum < target:
            left += 1
        else:
            right -= 1

    return [-1, -1]

This runs in O(n)O(n) time and O(1)O(1) space (excluding input). Each element is visited at most once.