1class Solution:
2 def permute(self, nums: List[int]) -> List[List[int]]:
3 results = []
4 def backtrack(start_index, used, path):
5 if len(path) == len(nums):
6 results.append(path)
7 return
8
9 for i, num in enumerate(nums):
10 if used[i]:
11 continue
12 used[i] = True
13 backtrack(start_index + 1, used, path + [num])
14 used[i] = False
15
16 backtrack(0, defaultdict(bool), [])
17 return results
Solution to "Count Number of Texts" question on Leetcode.
Solution to "Second Minimum Node In a Binary Tree" on Leetcode.