Skip to content

Commit 0eb086e

Browse files
committed
Update solution 046 [Python3]
1 parent f4f2adb commit 0eb086e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

solution/046.Permutations/Solution.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def permute(self, nums):
3+
"""
4+
:type nums: List[int]
5+
:rtype: List[List[int]]
6+
"""
7+
if len(nums) <= 1:
8+
return [nums]
9+
ans = []
10+
for i, num in enumerate(nums):
11+
n = nums[:i] + nums[i+1:]
12+
for y in self.permute(n):
13+
ans.append([num] + y)
14+
return ans
15+

0 commit comments

Comments
 (0)