Easy
Two Sum
Given a list of integers and a target, print the two zero-based indices whose values add up to the target, smaller index first. Input: first line n and target, second line n integers. Exactly one answer exists.
Sample input
4 9 2 7 11 15
Expected output
0 1
Stuck? Read how to approach Two Sum: what the interviewer looks for, an answer outline and common mistakes.
OUTPUT
Press Run tests to check your code, or Run to try the input on the left. Everything runs in your browser.
Passing the tests is half the round
In an interview you also explain the approach, state the complexity and handle a follow-up while someone listens. Max asks this exact question, pushes on the weak spots and scores you at the end.
Practice with MaxFree: a 5-minute voice round and unlimited typed drills, with scored feedback. No card, and your camera is never recorded.