Seven line Python Solution by Recursion

  • 0
    class Solution(object):
        def permute(self, nums):
            :type nums: List[int]
            :rtype: List[List[int]]
            if len(nums) == 1:
                return [nums]
            res = []
            for i in range(len(nums)):
                tmp = [[nums[i]]+item for item in self.permute(nums[:i]+nums[i+1:])]
            return res

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.