classSolution:defsubsets(self,nums: List[int]) -> List[List[int]]: ans = [] n =len(nums)defbacktrack(k,curr,start):iflen(curr)== k: ans.append(list(curr))returnfor i inrange(start, n): curr.append(nums[i])backtrack(k, curr, i +1) curr.pop()for k inrange(len(nums) +1):backtrack(k, [], 0)return ans