class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
L = len(nums)
ans = [[]]
def recurse(index, arr):
nonlocal ans
if index < L:
recurse(index + 1, arr + [nums[index]])
recurse(index + 1, arr)
else:
ans.append(arr)
for index, e in enumerate(nums):
recurse(index + 1, [e])
return ans
Β