Subsets II
Problem
Given a list of numbers that may has duplicate numbers, return all possible subsets
Example
If S = [1, 2, 2]
, a solution is:
[
[2],
[1],
[1,2,2],
[2,2],
[1,2],
[]
]
Note
- Each element in a subset must be in non-descending order.
- The ordering between two subsets is free.
- The solution set must not contain duplicate subsets.
Challenge
Can you do it in both recursively and iteratively?
Key Point
Elements in a subset must be in non-descending order.