-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLC90.py
More file actions
27 lines (22 loc) · 680 Bytes
/
LC90.py
File metadata and controls
27 lines (22 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Solution(object):
def subsetsWithDup(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
if not nums:
return []
nums.sort()
vis = set()
ans = []
def helper(index,path,vis,nums):
if tuple(path) in vis:
return
vis.add(tuple(path))
ans.append([i for i in path])
for i in range(index,len(nums)):
path.append(nums[i])
helper(i+1,path,vis,nums)
path.pop()
helper(0,[],vis,nums)
return ans