Skip to main content
Medium Backtracking Medium frequency

Subsets II

Open on LeetCode

Approach Summary

Sort input. Backtrack with start index. Skip duplicates at the same level: if i > start && nums[i] == nums[i-1], continue.

How to Recognize This Pattern

  • Subsets with duplicate numbers — avoid duplicate subsets
  • Sort + skip duplicates at same recursion depth

Complexity Analysis

Time Complexity

O(n × 2ⁿ)

Space Complexity

O(n)

Tags

Array Backtracking Bit Manipulation

This site is free. If these guides are helping your prep, consider buying me a coffee. ☕

Support →
Buy me a coffee