This is a classic backtracking problem , i dont know why we need to copy arr element inside recursive function in order for it to work correctly. If i dont copy. It will return blank array
def subsets(self, nums: List[int]) -> List[List[int]]:
res = list()
temp = list()
def dfs(nums,i):
if i==len(nums):
res.append(temp.copy())
return
temp.append(nums[i])
dfs(nums,i+1)
temp.pop()
dfs(nums,i+1)
dfs(nums,0)
return res