标签:itertools collect put self solution output col def tools
Given a collection of distinct integers, return all possible permutations.
Example:
Input: [1,2,3]
Output:
[
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2],
[3,2,1]]
import itertools
class Solution:
def permute(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
l = list(itertools.permutations(nums,len(nums)))
return l
标签:itertools collect put self solution output col def tools
原文地址:https://www.cnblogs.com/bernieloveslife/p/9733239.html