My concise python solution


  • 1
    L
    def permuteUnique(self, num):
        # find count of elements in num
        d = collections.Counter(num)
                
        solutions = [[]]
        for item in xrange(len(num)):
            solutions = [solution + [i]  \
                            for solution in solutions \
                            for i in d \
                            if d[i] > solution.count(i) ]
        return solutions

Log in to reply
 

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