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

Quiz: STL Algorithms · Question 2 of 10

What must you do before calling unique to remove all duplicates?

What must you do before calling unique to remove all duplicates?

  1. A.Reverse the vector
  2. B.Sort it
  3. C.Clear it
  4. D.Nothing
Answer & explanation

Correct answer: Sort it

unique removes only ADJACENT duplicates, so sort first.

Can you get the rest right without peeking?

Take the timed Quiz: STL Algorithms quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →