LC090 - Subsets II
Last updated
Last updated
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 solution in any order.
Input: nums = [1,2,2]
Output: [[],[1],[1,2],[1,2,2],[2],[2,2]]
Do a DFS and backtrack to get all subsets. Time and space complexity is .
Use bit masking to come up with the power set. Replace pow with bit shift to speed up computation.
Time complexity is still but with a smaller constant time factor than the backtracking solution.