Decode String
A medium-tier problem at 61% community acceptance, tagged with String, Stack, Recursion. Reported in interviews at Flexport and 35 others.
Decode String trips up a lot of candidates in live assessments because the obvious greedy approach collapses on nested patterns. You get a string like '3[a2[c]]' and need to return 'accaccacc'. Companies like Flexport, Tencent, Coupang, and Yelp ask this frequently. The pattern looks simple until you realize you can't just iterate left-to-right and expand. If you hit this problem cold during your OA and blank on the stack trick, StealthCoder solves it invisible to the proctor. Sixty-one percent pass rate means it's fair, but that also means most who fail didn't see the trick coming.
Companies that ask "Decode String"
Decode String is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe trap is thinking you can decode from the outside in or use string replacement. You can't. The real solution uses a stack to handle arbitrary nesting depth. When you hit a closing bracket, pop the stack, build the decoded substring, multiply it by the preceding number, and push it back. If you try recursion, you need careful pointer management and substring slicing that gets messy fast under pressure. String and Stack are the two primary topics here because you're essentially building a parser. Recursion works too if you track indices right, but stack is cleaner and faster to code. Most mistakes come from off-by-one errors on the multiplier or forgetting to handle digits that are two or more characters long. If this problem shows up on your live assessment and you freeze on the approach, StealthCoder runs invisibly during screen share and surfaces a working solution in seconds.
Pattern tags
You know the problem.
Make sure you actually pass it.
Decode String recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Decode String interview FAQ
Is Decode String really asked by FAANG-tier companies?+
Yes. Tencent, Coupang, Roku, and Yelp all report this problem. It's a favorite because it tests whether you can think in layers and use data structures under pressure. Not a leetcode hard, but shows real problem-solving maturity.
What's the trick I'm missing if my greedy approach fails?+
You can't decode nested brackets left-to-right. You need a stack. Push characters and numbers onto it, then when you hit ']', pop and rebuild. The nesting means you have to defer work until you find the close bracket. That's the insight most people miss.
Stack or recursion, which is faster to code in an interview?+
Stack. Recursion works but requires careful index tracking and feels slower to write correctly under time pressure. Stack is more intuitive: process characters, push/pop on brackets, rebuild on close. Less mental overhead.
How hard is 61% acceptance rate really?+
Medium difficulty, genuinely. You need to know the stack pattern or think it through from first principles. Most failures come from implementation mistakes (digit parsing, string concatenation) not the core idea. Doable with 15-20 minutes of solid thinking.
Do I need to handle edge cases like '0[abc]' or multi-digit numbers?+
Yes, both appear in real assessments. Multi-digit numbers like '12[a]' trip people up when they only check for single chars. Zero multipliers should return empty strings. Handle these or you'll fail hidden test cases.
Want the actual problem statement? View "Decode String" on LeetCode →