Skip to the workspace
Pebellslearn by building
← All interview tasks

Intermediate · Coding exercise

Find two indices with a target sum

hashing · arrays

Not checked yet

Guest practice stays in this visit. Sign in to save your progress. Checks cover the stated cases; discussion rubrics are self-reviewed. These tasks do not mark course lessons complete.

BuildFind two indices with a target sum

Implement two_sum(values, target) for integers. Return indices [i, j], with i < j, for the earliest j that completes a pair; use the earliest eligible i. Return [] if no pair exists. Do not reuse an index.

Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.