leetcode Count and Say
来源:互联网 发布:比较好的java入门书籍 编辑:程序博客网 时间:2024/05/02 02:11
代码
class Solution {public: string countAndSay(int n) { string s = ""; if(n==0) return s; for(int i = 1; i <= n; ++i) s = countAndSayHelper(s); return s; } string countAndSayHelper(string &s) { if(s.size()==0) return "1"; string temp = ""; for(int i = 0; i < s.size(); ++i) { int cnt = 1; while(i+1<s.size()&&s[i]==s[i+1]) { cnt++; i++; } temp += (cnt+'0'); temp += s[i]; } return temp; }};
0 0
- LeetCode: Count and Say
- [LeetCode]Count and Say
- LeetCode Count and Say
- [Leetcode] Count and Say
- Leetcode: Count and Say
- [LeetCode] Count and Say
- LeetCode Count and Say
- [LeetCode]Count and Say
- [LeetCode] Count and Say
- LeetCode-Count and Say
- LeetCode: Count and Say
- LeetCode - Count and Say
- [LeetCode] Count and Say
- Count and Say 【leetcode】
- [LeetCode] Count and Say
- Leetcode Count and Say
- LeetCode Count and Say
- LeetCode | Count and Say
- 「四」创建一个带 apache 服务的镜像
- Java分支语句
- C语言_高级指针
- 《动态表情的时空流形上的表示基expressionlet学习》学习总结
- 【并查集】【bzoj 1116】: [POI2008]CLO
- leetcode Count and Say
- Day10_c语言_高级指针练习
- 数组的内存管理
- 判断一个图片是不是伪造的方法
- [linux,c++] 使用指针函数实现多个函数调用
- Linux Lvs负载均衡集群技术(二)
- Android漏洞——将Android恶意代码隐藏在图片中
- 2015考研之十八届四中全会专项考点分析
- web项目开发处理乱码问题