 All Problems
Subsets II
medium
backtracking
arrays
bit manipulation
amazon
facebook
google

Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the answer in lexicographic order.

Example 1:

Input: 1 2 2
Output:

1
1 2
1 2 2
2
2 2

Example 2:

Input: 0
Output:

0

Constraints:

  • 1 ≤ nums.length ≤ 10
  • -10 ≤ nums[i] ≤ 10

Input format: Space-separated integers (may have duplicates).

Output format: Each subset on its own line (sorted), empty line for empty subset.

Run to check your code against the sample cases, or submit to run every case