Question bank › Recursion
Dsa Recursion Hard

Permutations of a String

Write a program to generate all possible permutations of a given string. The input will be a single string, and the output should be a list of all unique permutations sorted in lexicographical order. Input Format: - A single line containing the input string. Output Format: - A list of strings, each representing a unique permutation of the input string, sorted lexicographically. Example: Input: abca Output: ['aabc', 'abac', 'abca', 'acab', 'baac', 'baca', 'caba', 'cbaa']

Key concepts

recursionbacktrackingstring

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.