Back to exercises

Two Sum

Store each seen number in a dictionary keyed by value. For each new number, check whether target minus number has already appeared.

Coding Exercises Easy O(n)

Two Sum

Store each seen number in a dictionary keyed by value. For each new number, check whether target minus number has already appeared.

Return the indices of two numbers that add up to a target.