diff --git a/LeetCode/0046_Permutations.py b/LeetCode/0046_Permutations.py new file mode 100644 index 0000000..4456739 --- /dev/null +++ b/LeetCode/0046_Permutations.py @@ -0,0 +1,12 @@ +class Solution: + def permutations(self, nums: List[int]): + if not nums: + yield [] + for num in nums: + remaining = list(nums) + remaining.remove(num) + for perm in self.permutations(remaining): + yield [num] + list(perm) + + def permute(self, nums: List[int]) -> List[List[int]]: + return list(self.permutations(nums))