38. Count and Say
来源:互联网 发布:ipad监控软件 编辑:程序博客网 时间:2024/05/01 21:13
题目摘要
报数指的是,按照其中的整数的顺序进行报数,然后得到下一个数。如下所示: 1, 11, 21, 1211, 111221, ...
给定一个整数 n, 返回 第 n 个序列。
解法
从n = 1开始(while (--n > 0)
),新建一个StringBuilder,用双指针法遍历该字符串,往sb里添加字符
注意
原题
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ...
1
is read off as "one 1"
or 11
. 11
is read off as "two 1s"
or 21
. 21
is read off as "one 2, then one 1"
or 1211
.
Given an integer n, generate the nth sequence.
0 0
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- 38. Count and Say
- MySql常见错误
- 精通 CSS+DIV 网页样式与布局 9
- bzoj1096
- Fragment与Activity的生命周期
- 大数据技术概况
- 38. Count and Say
- 精通 CSS+DIV 网页样式与布局 10
- 第14周项目2-二叉树排序树中查找的路径
- 【C语言】leetcode 67. Add Binary
- 泛型应用
- 29 leetcode - Divide Two Integers
- git学习笔记
- Android利器之Service
- 域名和网络地址结构体---struct hostent