46. A buckle arrangement full force leetcode

Given a sequence of numbers is not repeated, all possible return to full permutation.

Example:

Input: [1,2,3]
Output:
[
  [1,2,3],
  [1,3,2],
  [2,1,3],
  [2,3,1],
  [3,1,2 ],
  [3,2,1]
]

a python built-in function

class Solution(object):
    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        res = itertools.permutations(nums,len(nums))

        return res

 

Published 302 original articles · won praise 161 · views 490 000 +

Guess you like

Origin blog.csdn.net/qq_32146369/article/details/104106144