Given a string s, the goal is to return a list of all unique permutations of the string, including those that may contain duplicate characters, and return them in lexicographical order.
Example 1
Input: "AAB"
Output: ["AAB", "ABA", "BAA"]
Explanation: The string "AAB" has 3 unique permutations due to duplicate characters: "AAB", "ABA", and "BAA".
Example 2
Input: "ABBA"
Output: ["AABB", "ABAB", "ABBA", "BAAB", "BABA", "BBAA"]
Explanation: The string "ABBA" has 6 unique permutations, accounting for duplicate characters.
Sign in to write, run, and submit your solution against the full test suite.