61. Repeated Message
Medium
Decode texto, which uses the k[trecho] notation to repeat a segment exactly k times. Repetitions can be nested, and k may have more than one digit. Letters outside the brackets appear once.
Example 1
Input: texto = "2[ab3[c]]"
Output: "abcccabccc"
Explanation: The segment `c` appears three times, and the group `abccc` appears twice.
Example 2
Input: texto = "3[x]y"
Output: "xxxy"
Constraints
- 1 <= texto.length <= 100
- `texto` contains lowercase letters, digits, and balanced brackets.
- The decoded result has at most 10^4 characters.
StringsStackRecursion
Saved in this browser
Caso 1
texto =
"2[ab3[c]]"
Expected =
"abcccabccc"
Caso 2
texto =
"3[x]y"
Expected =
"xxxy"
Run checks these 2 cases. Submit runs all 6, including hidden ones.