LeetCode - Count and Say
来源:互联网 发布:运维java中间件有哪些 编辑:程序博客网 时间:2024/06/08 06:15
第一遍交的时候理解错题目意思了 还以为是读n...
public String countAndSay(int n) {String result = "1"; for (int i = 1; i < n; i ++) { result = getResult(result); } return result; }public String getResult(String number){ String result = ""; int count = 0; String digit = number.substring(0, 1); for (int i = 0; i < number.length(); i ++) { String sub = number.substring(i, i + 1); if (sub.equals(digit)){ count ++; } else { result += count + digit; count = 1; digit = sub; } } result += count + digit; return result;}
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
- Project 10:简单图像的绘制
- Excel的奇特功能——图片去重
- 数据结构拾遗(1) --红黑树的设计与实现(上)
- Android | Vuforia 更换Target
- win7建立wifi热点
- LeetCode - Count and Say
- Linux使用技巧3--用dd命令制作U盘系统启动盘
- BitmapData.draw比BitmapData.copyPixel能做得更多
- java学习(给对象制作的简单的有背景音乐的电子相册)
- 知识积累
- LeetCode - Excel Sheet Column Number
- Set Matrix Zeroes - Leetcode
- RabbitMQ
- 天声人語 20150217