← Quiz: Technical Interviews: all 10 questions
Quiz: Technical Interviews · Question 4 of 10
What is the time complexity of Two Sum with a hash map?
What is the time complexity of Two Sum with a hash map?
- A.O(n²)
- B.O(n)
- C.O(log n)
- D.O(1)
Answer & explanation
Correct answer: O(n)
One pass with constant-time lookups.
Can you get the rest right without peeking?
Take the timed Quiz: Technical Interviews quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →