Given an array of integers that is already sorted in ascending absolute order, find two numbers so that the sum of them equals a specific number.
The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Note: the subscript of the array starts with 0
You are not allowed to sort this array.
Example
Input:
[0,-1,2,-3,4]
1
Output: [[1,2],[3,4]]
Explanation: nums[1] + nums[2] = -1 + 2 = 1, nums[3] + nums[4] = -3 + 4 = 1
You can return [[3,4],[1,2]], the system will automatically help you sort it to [[1,2],[3,4]]. But [[2,1],[3,4]] is invaild.
Challenge
O(n) time complexity and O(1) extra space
Notice
It is guaranteed that all numbers in thenumsnumsnums is distinct.