Dsa
Backtracking
Warm-up
String Permutations
Given a string, return all possible unique permutations of the characters in the string. The permutations should be printed in sorted order. Each permutation should be on a new line.
Input:
The input consists of a single line containing a string.
Output:
The output should contain each unique permutation, sorted in lexicographically, each on a new line.
Example:
Input:
aab
Output:
aaab
aba
baa
Key concepts
backtrackingpermutationsstrings
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now