class Solution {
public:
string decodeString(string s) {
stack<string> chars;
stack<int> nums;
string res;
int num = ; for (char c: s) {
if (isdigit(c))
num = num * + (c - '');
else if (isalpha(c)) {
res += c;
} else if (c == '[') {
chars.push(res);
nums.push(num);
res = "";
num = ;
} else {
string tmp = res;
for (int i = ; i < nums.top() - ; i++)
res += tmp;
res = chars.top() + res;
chars.pop();
nums.pop();
}
} return res;
}
};

leetcode394的更多相关文章

  1. [Swift]LeetCode394. 字符串解码 | Decode String

    Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where ...

  2. LeetCode-394. Decode String(DFS)

    Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where ...

  3. LeetCode394 字符串解码

    给定一个经过编码的字符串,返回它解码后的字符串. 编码规则为: k[encoded_string],表示其中方括号内部的 encoded_string 正好重复 k 次.注意 k 保证为正整数. 你可 ...

随机推荐

  1. GraphHttpClient概述

    博客地址:http://blog.csdn.net/FoxDave 目前这个东西还在预览阶段,所以不推荐在正式生产环境中使用. 我们可以使用Microsoft Graph接口来构建强大的解决方案来访问 ...

  2. js实现上拉加载思路整理

    1.整体模拟滚动 监听touchmove事件,比较 scrollTop 和 $scroller.scrollHeight() - $container.height(). 缺点:滑动不流畅, tran ...

  3. CHECK约束表达式

    1.性别:只能填写'男'和'女' (字段名='男'or 字段名='女') 注意:单引号里的值可以为其他任何字 2.规定密码长度不能小于6位数 (len([字段名])>(5))   3.例:成绩在 ...

  4. react native 开发报错

    1:oc对象名是RCTPoctalk 2:js中导入原生方法 3:报错:对象没有定义 出现这样的问题可能是react native 不允许使用“RCT”开头的前缀 4:解决办法:“RCT_EXPORT ...

  5. C#获取文件目录

    Form1.cs using System;using System.Collections.Generic;using System.ComponentModel;using System.Data ...

  6. 如何使用HackRF做一个简单的IMSI捕获器

    关于IMSI IMSI为国际用户识别码(International Mobile Subscriber Identity)的缩写,是用于区分蜂窝网络中不同用户的,在所在蜂窝网络中不重复的识别码.IMS ...

  7. MYSQL数据模型

    DROP TABLE IF EXISTS `sh_category`; CREATE TABLE `sh_category` ( `id` int(11) NOT NULL AUTO_INCREMEN ...

  8. flask自定义处理错误方法

    自定义错误处理方法: 当客户端访问浏览器是,得到相对应的状态码,服务器通过状态码给用户相对应的页面. @app.errorhandler(404) def handle_404_error(err): ...

  9. A Language Modeling Approach to Predicting Reading Difficulty-paer

    Volume:Proceedings of the Human Language Technology Conference of the North American Chapter of the ...

  10. windows server 2008 R2之tomcat开机自启

    方法一: 写一个批处理文件autostartup.bat用来启动tomcat,内容如下.复制时不要把复制内容也复制进去 set CATALINA_HOME=C:\apache-tomcat-8.5.3 ...