← 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)
- A.To use two pointers for the remaining pair
- B.To skip duplicate values easily
- C.Because the output must be sorted
- 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 →