leetcode394】的更多相关文章

Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_stringinside the square brackets is being repeated exactly k times. Note that kis guaranteed to be a positive integer. You may assume that…
class Solution { public: string decodeString(string s) { stack<string> chars; stack<int> nums; string res; ; for (char c: s) { if (isdigit(c)) num = num * + (c - '); else if (isalpha(c)) { res += c; } else if (c == '[') { chars.push(res); nums…
Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume th…
给定一个经过编码的字符串,返回它解码后的字符串. 编码规则为: k[encoded_string],表示其中方括号内部的 encoded_string 正好重复 k 次.注意 k 保证为正整数. 你可以认为输入字符串总是有效的:输入字符串中没有额外的空格,且输入的方括号总是符合格式要求的. 此外,你可以认为原始数据不包含数字,所有的数字只表示重复的次数 k ,例如不会出现像 3a 或 2[4] 的输入. 示例: s = "3[a]2[bc]", 返回 "aaabcbc&quo…