HTMLify

LeetCode - Permutations - Python
Views: 10 | Author: abh
class Solution:
    def permute(self, nums: List[int]) -> List[List[int]]:
        if len(nums) == 1: return [[nums[0]]]
        combs = []
        for n in nums:
            tnums = nums.copy()
            tnums.remove(n)
            scombs =  self.permute(tnums)
            for scomb in scombs:
                combs.append([n]+scomb)
        return combs

Comments