text function twoSum(numbers, target): left = 0 right = length(numbers) - 1 while left < right: sum = numbers[left] + numbers[right] if sum == target: return [left + 1, right + 1] else if sum < target: left = left + 1 else: right = right - 1 Time complexity: . Each pointer moves at most n times. Space complexity: . Only two pointer variables.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/two-pointers-sliding-window/two-sum-ii-pseudocode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████████████████████