8268 {
8269 int i = 0;
8270 vector<int> cnt;
8271 vector<string> strs;
8272 while(i < s.length()) {
8273 if(isalpha(s[i]) != 0) {
8274 cnt.emplace_back(1);
8275 strs.emplace_back(string(1, s[i]));
8276 i++;
8277 } else if(isdigit(s[i]) != 0) {
8278 int j = i + 1;
8279 while(j < s.length() && isdigit(s[j]) != 0) {
8280 j++;
8281 }
8282 cnt.emplace_back(stoi(s.substr(i, j - i)));
8283 i = j;
8284 int level = 1;
8285 while(level > 0) {
8286 j++;
8287 if(s[j] == '[') {
8288 level++;
8289 } else if(s[j] == ']') {
8290 level--;
8291 }
8292 }
8293 strs.emplace_back(
decodeString(s.substr(i + 1, j - i - 1)));
8294 i = j + 1;
8295 }
8296 }
8297 ostringstream oss;
8298 for(i = 0; i < cnt.size(); i++) {
8299 for(int j = 0; j < cnt[i]; j++) {
8300 oss << strs[i];
8301 }
8302 }
8303 return oss.str();
8304 }
static string decodeString(string s)