90. 子集 II
套模板,可参考:https://www.cnblogs.com/panweiwei/p/14025143.html
class Solution(object):
def __init__(self):
self.res = []
def subsetsWithDup(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
if not nums:
return []
nums.sort()
n = len(nums)
self.dfs(nums, n, 0, [])
return self.res
def dfs(self, nums, n, begin, temp):
if temp not in self.res:
self.res.append(temp)
for i in range(begin, n):
if i > begin and nums[i] == nums[i - 1]:
continue
self.dfs(nums, n, i + 1, temp + [nums[i]])