Question bank › Stack
Dsa Stack Hard

Decode String

Given an encoded string, decode it to produce the original string. The encoding uses a form k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. You may assume that the input string is always valid. It is guaranteed that the decoding will result in a string that has at most 10^5 characters. Input format: A single line containing the encoded string. Output format: Print the decoded string. Example: Input: 3[a2[c]] Output: accaccacc

Key concepts

stackdecodingmanipulation

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.