⚡ AlgoZen_

Two Sum

Beginner

Given an array and a target, find two indices whose values sum to the target. Use a hash map to achieve O(n) — store each value's index and check if the complement already exists.

time:O(n)
space:O(n)
⚡ +100_XP
step[1/5]
> Start
2
7
11
15
Find two numbers in [2, 7, 11, 15] that add up to 9. Use a hash map for O(n) time.

// tap NEXT STEP to walk through one step at a time