Leetcode腾讯精选_编号:46 --python
2019-02-27 12:20
351 查看
给定一个没有重复数字的序列,返回其所有可能的全排列。
示例:
输入: [1,2,3]
输出:
[
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2],
[3,2,1]
]
class Solution(object): def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ if len(nums) <= 1: return [nums] res=[] for i,num in enumerate(nums): s=nums[:i]+nums[i+1:] for x in self.permute(s): res.append([num]+x) return res
相关文章推荐
- Leetcode腾讯精选_编号:88 --python
- Leetcode腾讯精选_编号:89 --python
- Leetcode腾讯精选_编号:104 --python
- Leetcode腾讯精选_编号:231 --python
- Leetcode腾讯精选_编号:235 --python
- Leetcode腾讯精选_编号:236 --python
- Leetcode腾讯精选_编号:237 --python
- Leetcode腾讯精选_编号:121 --python
- Leetcode腾讯精选_编号:292 --python
- Leetcode腾讯精选_编号:136 --python
- Leetcode腾讯精选_编号:344 --python
- Leetcode腾讯精选_编号:141 --python
- Leetcode腾讯精选_编号:557 --python
- Leetcode腾讯精选_编号:151 --python
- Leetcode腾讯精选_编号:169 --python
- Leetcode腾讯精选_编号:53 --python
- Leetcode腾讯精选_编号:206 --python
- Leetcode腾讯精选_编号:61 --python
- Leetcode腾讯精选_编号:217 --python
- Leetcode腾讯精选_编号:70 --python