Locked

Pass the Dictionary check first

Everything after it builds on dictionaries. Each rep in the check has to be passed without opening the solution. Hints and Basics are fine.

Still to clear · 8 of 8

Continue the check

Preview · where this ladder is heading

Two Sum II (sorted input)

numbers is sorted from smallest to largest, and values may repeat. Exactly one pair of different positions adds up to target. Return their positions as a list [a, b], with a < b. Use 1-based positions: the first item is position 1.

Use O(1) extra space: no dict or set.

two_sum_sorted([2, 7, 11, 15], 9) → [1, 2] (2 + 7) two_sum_sorted([2, 3, 4], 6) → [1, 3] (2 + 4)

innumbers = [2, 7, 11, 15], target = 9out[1, 2]
innumbers = [2, 3, 4], target = 6out[1, 3]
innumbers = [-1, 0], target = -1out[1, 2]

You can read it now. The editor opens when the check is cleared.