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

Recursion & Backtracking Quiz · Question 7 of 7

To avoid duplicate combinations when the input has repeated numbers (Subsets II), you… (select all that apply)

To avoid duplicate combinations when the input has repeated numbers (Subsets II), you… (select all that apply)

  1. A.Sort the input first
  2. B.Skip nums[i] when it equals nums[i−1] at the same recursion level
  3. C.Use a stack instead of recursion
  4. D.Reverse the input
Answer & explanation

Correct answer: Sort the input first · Skip nums[i] when it equals nums[i−1] at the same recursion level

Sorting puts equal values together; skipping them at the same level avoids generating identical branches.

Can you get the rest right without peeking?

Take the timed Recursion & Backtracking Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →