arrow_back Back to Challenges

#394 Decode String

Medium Acceptance 0%
description

Problem Description

Given an encoded string, return its decoded string. The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is being repeated exactly `k` times.

checklist Constraints

1 <= s.length <= 30
s consists of lowercase English letters, digits, and square brackets '[]'.
s is guaranteed to be a valid input.
All the integers in s are in the range [1, 300].

science Examples

Case #1

In: s = "3[a]2[bc]"
Out: "aaabcbc"

Case #2

In: s = "3[a2[c]]"
Out: "accaccacc"

Mastery Tags

Recursion Stack Strings

Hiring Companies

Amazon Bloomberg Google
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude