<filename>src/046.permutations.py
class Solution:
    # def permute(self, nums: List[int]) -> List[List[int]]:
    #     from itertools import permutations
    #     return list(permutations(nums))

    def permute(self, nums: List[int]) -> List[List[int]]:
        return [[n] + p
                for i, n in enumerate(nums)
                for p in self.permute(nums[:i] + nums[i+1:])] or[[]]

<filename>src/046.permutations.py
class Solution:
    # def permute(self, nums: List[int]) -> List[List[int]]:
    #     from itertools import permutations
    #     return list(permutations(nums))

    def permute(self, nums: List[int]) -> List[List[int]]:
        return [[n] + p
                for i, n in enumerate(nums)
                for p in self.permute(nums[:i] + nums[i+1:])] or[[]]

# def permute(self, nums: List[int]) -> List[List[int]]: #     from itertools import permutations #     return list(permutations(nums))