#K15066. Unique Lexicographical String Permutations
Unique Lexicographical String Permutations
Unique Lexicographical String Permutations
Given a string \( S \) consisting of uppercase English letters (A-Z), your task is to generate all unique permutations of \( S \) in lexicographical order. Each permutation should be printed on a new line.
Example:
Input: AAB Output: AAB ABA BAA
Be sure to handle duplicate characters properly so that each permutation appears only once.
inputFormat
The input consists of a single string \( S \) containing only uppercase letters. \( S \) may include duplicate characters.
outputFormat
Output all unique permutations of \( S \) in lexicographical order. Each permutation must be printed on its own line.
## sampleAAB
AAB
ABA
BAA
</p>