1-line Python solution, set, list slicing, beats 46.11%


  • 3
    K

    Inspired by this one-liners.

    def permuteUnique(self, nums):
        return [[n] + p for n in set(nums) for p in self.permuteUnique(nums[:nums.index(n)] + nums[nums.index(n) + 1:])] or [[]]
    

Log in to reply
 

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