From b91b1b996f894a38d9345e663b9941034fe802ab Mon Sep 17 00:00:00 2001 From: ayush_manglani <61349816+Ayushmanglani@users.noreply.github.com> Date: Mon, 5 Oct 2020 00:28:38 +0530 Subject: [PATCH 1/2] #0046_Permutations.py --- LeetCode/Permutations.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 LeetCode/Permutations.py diff --git a/LeetCode/Permutations.py b/LeetCode/Permutations.py new file mode 100644 index 0000000..4456739 --- /dev/null +++ b/LeetCode/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)) From 50b0ab07dbe3d5ef8e827135bf9fed9e6970b874 Mon Sep 17 00:00:00 2001 From: ayush_manglani <61349816+Ayushmanglani@users.noreply.github.com> Date: Mon, 5 Oct 2020 00:29:53 +0530 Subject: [PATCH 2/2] Created 0046_Permutations.py --- LeetCode/{Permutations.py => 0046_Permutations.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LeetCode/{Permutations.py => 0046_Permutations.py} (100%) diff --git a/LeetCode/Permutations.py b/LeetCode/0046_Permutations.py similarity index 100% rename from LeetCode/Permutations.py rename to LeetCode/0046_Permutations.py