'''
recursive method
'''

class Solution(object):
    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        if len(nums) <= 1: 
            return [nums]
        
        rst = []
        for i in range(len(nums)):
            s = nums[:i] + nums[i+1:]  
            p = self.permute(s)  
            for x in p:  
                rst.append(nums[i:i+1] + x)  
        return rst 

9c2db13061edb2ee834c5f1b5276d3ee11e45c2e
<mask token>

<mask token>


class Solution(object):
    <mask token>

<mask token>


class Solution(object):

    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        if len(nums) <= 1:
            return [nums]
        rst = []
        for i in range(len(nums)):
            s = nums[:i] + nums[i + 1:]
            p = self.permute(s)
            for x in p:
                rst.append(nums[i:i + 1] + x)
        return rst

'''
recursive method
'''

class Solution(object):
    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        if len(nums) <= 1: 
            return [nums]
        
        rst = []
        for i in range(len(nums)):
            s = nums[:i] + nums[i+1:]  
            p = self.permute(s)  
            for x in p:  
                rst.append(nums[i:i+1] + x)  
        return rst 
