🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Technical Interviews: all 10 questions

Quiz: Technical Interviews · Question 7 of 10

What is the space complexity of the hash-map solution to Two Sum?

What is the space complexity of the hash-map solution to Two Sum?

  1. A.O(1)
  2. B.O(log n)
  3. C.O(n)
  4. D.O(n²)
Answer & explanation

Correct answer: O(n)

The map may store up to n numbers while scanning.

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 →