leetcode ----394. Decode String
来源:互联网 发布:js怎么关闭手机端页面 编辑:程序博客网 时间:2024/05/17 08:01
string decodeString(string s) { string tem; stack<int> stanum; //存储数字 stack<string> stastr;//存储字符串 int n=0; for(int i=0;i<s.length();i++) { if(isdigit(s[i]))//判断当前字符是否为0-9数字 { n = n*10+s[i]-'0';//计算当前数字 } else if(s[i]=='[') { stanum.push(n);//循环次数进栈 n=0;//初始化n stastr.push(tem);//上一次的tem进栈作为top tem.clear();//清空tem } else if(s[i]==']') { int k = stanum.top(); stanum.pop(); for(;k>0;k--) { stastr.top()+=tem;//top累加k次的tem } tem = stastr.top();//把stastr的top赋值给tem stastr.pop(); } else tem+=s[i];//tem一直累加 } return tem; }
0 0
- 【Leetcode】394. Decode String
- 【leetcode】394. Decode String
- leetcode ----394. Decode String
- [leetcode] 394. Decode String
- [Leetcode]394. Decode String
- 【LeetCode】 394. Decode String
- LeetCode 394. Decode String
- Leetcode 394. Decode String
- [leetcode]394. Decode String
- LeetCode 394. Decode String
- Leetcode-394. Decode String
- LeetCode 394. Decode String
- Leetcode 394. Decode String
- [LeetCode] 394. Decode String
- leetcode 394. Decode String
- LeetCode 394. Decode String
- LeetCode 394. Decode String
- leetcode-394. Decode String
- Linux用户和组的操作
- orc的plsql和动态sql
- 【计算机网络】 之 VLSM
- Android初级学习之Intent的简单使用
- 轮播
- leetcode ----394. Decode String
- TCP发送源码学习(1)--tcp_sendmsg
- Java8新特性之Collectors
- OSI七层模型与TCP/IP模型
- css常用单位及特点
- SearchAppoint——北京市预约挂号平台查询器
- 矩阵快速幂POJ-3070
- TCP发送源码学习(2)--tcp_write_xmit
- 数据仓库的架构以及数据分层