← All problems
Decode String (k[encoded])
Decode an encoded string with the pattern k[encoded_string], where the encoded string inside the brackets is repeated exactly k times. Nesting is allowed: '3[a2[c]]' decodes to 'accaccacc'. k is a positive integer.
Complexity
Time O(n * output), Space O(n)
Common pitfalls
- Single-digit count assumption
- Losing outer context on nesting
Your solution
Log in to save your code and track progress.