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

Two Pointers Quiz · Question 6 of 8

Why does 3Sum sort the array first? (select all that apply)

Why does 3Sum sort the array first? (select all that apply)

  1. A.To use two pointers for the remaining pair
  2. B.To skip duplicate values easily
  3. C.Because the output must be sorted
  4. D.To make it O(n)
Answer & explanation

Correct answer: To use two pointers for the remaining pair · To skip duplicate values easily

Sorting enables the two-pointer pair search and makes equal values adjacent for skipping. Overall it's O(n²).

Can you get the rest right without peeking?

Take the timed Two Pointers Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →