All Unique Permutations of a String

Problem Given a string s that may contain duplicate characters, return all unique permutations.

Input / Output

  • Input: string s.
  • Output: a list of all distinct permutations of s.

Constraints

  • 1 ≤ |s| ≤ 8.
  • Characters are uppercase English letters.

Example

  • s="ABA" → ["AAB","ABA","BAA"]
added …
LeaderboardSalaryAccount