Generate all permutations of a given string. Handle duplicate characters by returning only unique permutations.
Examples