Decode String

Given an encoded string, return its decoded string where the encoding rule is k[encoded_string] and the encoded_string inside the square brackets is repeated exactly k times. Assume the input string is valid, with well-formed brackets, no extra white spaces, and that digits appear only as repeat numbers.

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].
Saving… · 2 lines
class Solution:
def decodeString(self, s: str) -> str:
Console

Click Run to execute sample tests.