python - permutations

  • 0
    class Solution(object):
        def do_permute(self, nums, prefix, answer):
            if not nums:
            for num in nums:
                self.do_permute(nums - set([num]), prefix + [num], answer)
            return answer
        def permute(self, nums):
            :type nums: List[int]
            :rtype: List[List[int]]
            return self.do_permute(set(nums), [], [])

Log in to reply

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