Count and Say
来源:互联网 发布:mac 批量转换cr2 编辑:程序博客网 时间:2024/05/07 02:29
Notes: Before you understand the questions, you shouldn't start to code!
public class Solution { public String countAndSay(int n) { String seqString = "1"; if(1 == n){ return seqString; } String tmpString; for(int i = 2; i <= n; i++){ tmpString = ""; int cnt = 1, j; for(j = 1; j < seqString.length(); j++){ if (seqString.charAt(j) == seqString.charAt(j - 1)) {cnt++; } else {tmpString += cnt + "" + seqString.charAt(j-1);cnt = 1; } } tmpString += cnt + "" + seqString.charAt(j-1); seqString = tmpString; } return seqString; }}
0 0
- LeetCode: Count and Say
- [LeetCode]Count and Say
- LeetCode Count and Say
- [Leetcode] Count and Say
- Count and Say
- Leetcode: Count and Say
- [LeetCode] Count and Say
- LeetCode Count and Say
- Count and Say
- [38]Count and Say
- Count and Say
- Count and Say
- Count and Say
- [LeetCode]Count and Say
- Count and Say
- Count and Say
- [LeetCode] Count and Say
- LeetCode-Count and Say
- 黑马程序员——C语言基础篇---基本运算和位运算
- CDockablePane类的使用
- 事件拦截器hitTest:withEvent
- 百度地图在android的使用
- 通过teamviewer实现彻底的vpn
- Count and Say
- yii实战手册-Advanced版,解决advanced运行一闪而过的问题
- 天声人語 20150414
- 修改mysql数据库乱码的现象
- 【凯子哥带你做高仿】“煎蛋”Android版的高仿及优化(一)——逆向工程及TcpDump抓包入门
- 一个很好的免费的雷达测试数据及算法分析网站
- Oracle11g64位下使用PLSQL
- Python使用requests来抓取网页
- libxml/tree.h file not found