Skip to content
We areTOP 1%

Decode String

MediumLeetCodeStack & Queue
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

On an opening bracket, push the string built so far and the pending repeat count; on the matching closing bracket, repeat the inner string and append it to the saved prefix.

More in Stack & Queue

Stack & Queue questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Valid ParenthesesLeetCodeEasy Solve Valid Parentheses on LeetCode (opens in a new tab)
2Implement Queue using StacksLeetCodeEasy Solve Implement Queue using Stacks on LeetCode (opens in a new tab)
3Remove All Adjacent Duplicates In StringLeetCodeEasy Solve Remove All Adjacent Duplicates In String on LeetCode (opens in a new tab)
4Jzzhu and ChildrenCodeforcesEasy 1000Solve Jzzhu and Children on Codeforces (opens in a new tab)
5Move BracketsCodeforcesEasy 1000Solve Move Brackets on Codeforces (opens in a new tab)
6Social Network (easy version)CodeforcesEasy 1000Solve Social Network (easy version) on Codeforces (opens in a new tab)
7YetnotherrokenKeoardCodeforcesEasy 1000Solve YetnotherrokenKeoard on Codeforces (opens in a new tab)
8Even PositionsCodeforcesEasy 1100Solve Even Positions on Codeforces (opens in a new tab)
9Min StackLeetCodeMedium Solve Min Stack on LeetCode (opens in a new tab)
10Evaluate Reverse Polish NotationLeetCodeMedium Solve Evaluate Reverse Polish Notation on LeetCode (opens in a new tab)
11Asteroid CollisionLeetCodeMedium Solve Asteroid Collision on LeetCode (opens in a new tab)
12Decode StringLeetCodeMedium Solve Decode String on LeetCode (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account