167. Two Sum II - Input Array Is Sorted
mediumArray · Two Pointers · Binary Search
read the problem on leetcode →
first solved 14 Sept 2026
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
left = 0
right = len(numbers) - 1
while left < right:
total = numbers[left] + numbers[right]
if total == target:
return [left + 1, right + 1]
if total < target:
left += 1
else:
right -= 1