Created
March 15, 2019 03:08
-
-
Save ChongyeWang/4d251e78c7bbe36f23a3ca6e7b5b7f5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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