Dsa
Recursion
Medium
String Decompression
You are given a compressed string where each number indicates how many times the character immediately preceding it should repeat. For example, 'a2b3' would expand to 'aabbb'. Write a function to decompress such a string recursively.
Input Format:
- A single compressed string containing characters followed by their respective counts (e.g., 'a2b3').
Output Format:
- Print the decompressed string.
Example:
Input:
'a3b2'
Output:
aaaab
Key concepts
recursionstring processing
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