Count and Say
来源:互联网 发布:北京大学医学网络教育 编辑:程序博客网 时间:2024/06/08 16:58
public class Solution { public String countAndSay(int n) { if (n < 1) { return ""; } String res = "1"; for (int i = 0; i < n - 1; i++) { StringBuilder sb = new StringBuilder(); int count = 1; for (int j = 0; j < res.length(); j++) { if (j + 1 < res.length() && res.charAt(j) == res.charAt(j + 1)) { count++; } else { sb.append(count + "" + res.charAt(j)); count = 1; } } res = sb.toString(); } return res; }}
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
- 黄阶低级 - 《 Java 核心》- 4.7 包 - 修改0次
- Best Time to Buy and Sell Stock
- 根据前台设计数据库--首页篇
- adb
- 《bootstrap用户手册》读书笔记(1)
- Count and Say
- jenkins邮件插件中的内容参数设置详解
- React Native商城项目实战06 - 设置安卓中的启动页
- 遗传学算法
- IOS缓存机制详解
- 《C++Primer》读书笔记——第10章 泛型算法
- js的工厂模式
- 【贪心】Vijos P1615 旅行
- 【模板】SPFA