All Unique Permutations of an array

gfg, potd, python, medium

Problem Statement #

Given an array arr[] of length n. Find all possible unique permutations of the array.

Solution #

from itertools import permutations
class Solution:
    def uniquePerms(self, arr, n):
        # code here 
        result = []
        per = set(permutations(arr))
        for i in per:
            result.append(i)
        return sorted(result)