Leetocde#38||Count and Say
来源:互联网 发布:java sftp jcraft 编辑:程序博客网 时间:2024/06/02 01:39
public class Solution { public String countAndSay(int n) { if (n < 1) { return null; } String result = "1"; int t = n; while (t > 1) { char[] arr = result.toCharArray(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { int count = 1; while ((i + 1) < arr.length && arr[i] == arr[i + 1]) { count ++; i++; } sb.append(count); sb.append(arr[i]); result = sb.toString(); } t--; } return result; }}
0 0
- Leetocde#38||Count and Say
- [38]Count and Say
- 38Count and Say
- 38Count and Say
- 38、Count and Say
- [38] Count and Say
- 38-Count And Say
- [LeetCode 38] Count and Say
- LeetCode(38) Count and Say
- [leetcode 38] Count and Say
- [Leetcode] 38 - Count and Say
- leetcode-38 count and say
- [LeetCode 38]Count and Say
- LeetCode 38 Count and Say
- leetcode-38 Count and Say
- Leetcode 38 Count and Say
- Leetcode---(38)Count and Say
- leetcode 38: Count and Say
- 新oj 1534(poj 1201)
- oracle学习笔记(四)
- xoj1534(poj 1201)题解
- win7下android开发环境的搭建
- swift-tabbar的使用,页面之间的跳转
- Leetocde#38||Count and Say
- 3.[Python]多线程程序Ctrl+C的优雅终止
- swift- tableView 的使用
- LeetCode(209)Minimum Size Subarray Sum
- Leetcode#39||
- 最短路算法之dijkstra
- Leetcode#40||
- 两个二进制的异或结果是什么?P13
- iOS 浅赋值、深复制、完全复制的知识点梳理验证(附加归档解档)