Decode String Problem
Decode String Problem — ExecCode Medium DSA Practice
Solve the Decode String problem on ExecCode. Free online medium DSA practice in Stack. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given an encoded string, return its decoded string. The encoding rule is k[encodedstring] where the encodedstring inside the square brackets is repeated exactly k times. Nested encodings are allowed.
Examples
Input s = "2[a3[b]c]"; Output "abbbcabbbc". Input s = "3[a2[c]]"; Output "accaccacc". Input s = "3[a]2[bc]"; Output "aaabcbc"
Constraints
1 ≤ s.length ≤ 30 s consists of digits, letters, and square brackets.
Practice Decode String free on ExecCode. Browse DSA problems, topic map, and placement guides.