Dsa
Recursion
Easy
The Harmonic Echo
A signal is compressed using a nested repeat notation: 'count{content}'. For example, '2{A}' expands to 'AA', and '2{A3{B}}' expands to 'ABBBABBB'. Write a program to fully expand a given signal string. You may assume the input is always valid and counts are positive integers.
Input Format:
A single string containing letters, numbers, and curly braces.
Output Format:
The fully expanded string.
Example:
Input: 3{HI}2{B}
Output: HIHIHIBB
Key concepts
recursionstring parsingpattern expansion
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