Question bank › Strings
Dsa Strings Medium

Nested Frequency Expander

You are given a compressed string format where 'n(text)' means the 'text' inside the parentheses should be repeated 'n' times. Nesting can occur to any depth. Your task is to fully expand the string. Numbers are always single digits (1-9) for simplicity, but the resulting string can be long. Example: Input: 2(a3(b)c) Output: abbbbcabbbc (Explanation: 3(b) becomes bbb. Then 2(abbbc) becomes abbbbcabbbc.)

Key concepts

recursionstackstring-parsing

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