PythiloLesson 2 of 32 · progress kept in this browser

Meet in the middle with two pointers

In a sorted list, a pair that sums too low needs a larger left value and a pair that sums too high needs a smaller right value. Two indices moving toward each other test every useful pair once.

items = [1, 3, 4, 6, 9]
left, right = 0, len(items) - 1
print(items[left] + items[right])   # 10
Your task

Write pair_with_sum(items, target) for a sorted list. Return a tuple of two indices (i, j) with i < j whose values add up to target, or None.