Dsa
Backtracking
Hard
Permutations of String
You are given a string containing only unique characters. Your task is to return all possible permutations of the characters in the string. The permutations must be returned in lexicographical order. Print each permutation as a string.
Input:
- The first line is a single string (1 ≤ length ≤ 9) with unique uppercase characters.
Output:
- Print each permutation in lexicographical order, each on a new line.
Example:
Input:
ABC
Output:
ABC
ACB
BAC
BCA
CAB
CBA
Key concepts
backtrackingstringspermutations
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