(M)DFS: 394. Decode String
来源:互联网 发布:js 对象名 变量 编辑:程序博客网 时间:2024/05/13 03:29
好久都没做出来,看大神代码:
class Solution {public: string decodeString(const string& s, int& i) { string res; while (i < s.length() && s[i] != ']') { if (!isdigit(s[i])) res += s[i++]; else { int n = 0; while (i < s.length() && isdigit(s[i])) n = n * 10 + s[i++] - '0'; i++; // '[' string t = decodeString(s, i); i++; // ']' while (n-- > 0) res += t; } } return res; } string decodeString(string s) { int i = 0; return decodeString(s, i); }};
阅读全文
0 0
- (M)DFS: 394. Decode String
- 【leetcode】394. Decode String【M】【45ms】
- Decode String(leetcode),solved by DFS
- 【Leetcode】394. Decode String
- 394. Decode String
- 394. Decode String
- 394. Decode String
- 【leetcode】394. Decode String
- 394. Decode String
- leetcode ----394. Decode String
- 394. Decode String
- 394. Decode String
- 394. Decode String
- 394. Decode String
- [leetcode] 394. Decode String
- [Leetcode]394. Decode String
- 394. Decode String
- 【LeetCode】 394. Decode String
- NAS实现家用服务器
- newoj墓地3825: 王国的成熟度(树的深度)
- 记录我的Java学习经历(8)
- 租用游艇 dijkstra
- 生产管理——MES(制造执行系统)
- (M)DFS: 394. Decode String
- 【092】韦达定理在一元n次方程中的推广
- 问题积累
- C语言学习
- 谈一谈怎么成为一个Java高手
- 杭电ACM-A+B problem
- 15个常用的javaScript正则表达式
- 使用 hibernate 进行 批量删除
- HTTP无状态协议到底指的什么?