Question bank › Stack
Dsa Stack Medium

Decode String with Stack

You are given an encoded string where each string segment is represented in the format 'n[string]'. The value of 'n' indicates how many times the string needs to be repeated. Your task is to decode the entire string. Input: A single line string encoded in the described format. The length will be between 1 and 10000 characters. Output: The decoded string. Example: Input: 3[abc]2[de] Output: abcbcadeabcde

Key concepts

stackdecodingstring

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.