Dsa
Backtracking
Easy
Permutation Subsets
You need to generate all possible unique permutations of a given list of characters that may have duplicates. Each unique permutation should be output as a separate line.
Input:
- The first line contains an integer N (1 <= N <= 8), the size of the list.
- The second line contains N space-separated characters (can include duplicates).
Output:
- Print each unique permutation on a new line, sorted in lexicographical order.
Example:
Input:
3
a b a
Output:
['a', 'a', 'b']
['a', 'b', 'a']
['b', 'a', 'a']
Key concepts
backtrackingsubsetscombinatorics
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