Skip to content

Instantly share code, notes, and snippets.

@HauptJ
Created February 15, 2020 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HauptJ/0fbb657f18cc366dc88ac2236ae63486 to your computer and use it in GitHub Desktop.
Save HauptJ/0fbb657f18cc366dc88ac2236ae63486 to your computer and use it in GitHub Desktop.
class Solution:
def permute(self, nums: List[int]) -> List[List[int]]:
list = []
tempList = []
def backtrack(list, tempList, nums):
if len(tempList) == len(nums):
list.append(tempList)
else:
for i in range(0, len(nums), 1):
if nums[i] in tempList:
continue
else:
tempList.append(nums[i])
backtrack(list, tempList, nums)
del tempList[(len(tempList)-1)]
backtrack(list, tempList, nums)
return list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment