Skip to content

Instantly share code, notes, and snippets.

@ChongyeWang
Created March 15, 2019 03:08
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 ChongyeWang/4d251e78c7bbe36f23a3ca6e7b5b7f5b to your computer and use it in GitHub Desktop.
Save ChongyeWang/4d251e78c7bbe36f23a3ca6e7b5b7f5b to your computer and use it in GitHub Desktop.
class Solution(object):
def permute(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
result = []
temp = []
self.backtracking(result, temp, nums)
return result
def backtracking(self, result, temp, nums):
if len(temp) == len(nums):
result.append(temp[:])
return
for i in range(0, len(nums)):
if nums[i] in temp: continue
temp.append(nums[i])
self.backtracking(result, temp, nums)
temp.pop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment