Question bank › Recursion
Dsa Recursion Medium

String Combinations with Duplicates

Write a function that generates all possible unique combinations of characters from a given string, where characters can be duplicated. The function should print each combination in lexicographical order. The input format is as follows: First line: A single string (1 <= length <= 15, consisting of lowercase letters). Each letter can be repeated. Example: Input: aabc Output: a ab abc aa aac ac b bc c Each combination should be printed on a new line in sorted order, without duplicates.

Key concepts

recursioncombinatorial

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.