0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| class Solution: def permute(self, nums: List[int]) -> List[List[int]]: used,path,result = [False for _ in nums],[],[] def place_tree(nums): if len(path)==len(nums): result.append(path.copy()) for i in range(0,len(nums)): if used[i]==True: continue used[i] = True path.append(nums[i]) place_tree(nums) path.pop() used[i] = False return result return place_tree(nums)
|