def subsets1(nums):
res = []
nums.sort()
def dfs(index, path):
res.append(path)
for i in range(index, len(nums)):
dfs(i+1, path+[nums[i]])
dfs(0, [])
return res
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter