description: 就是看前面那个数有几个几,然后写一串。 Note: Example: answer: class Solution { public: string countAndSay(int n) { if (n ...
分类:
其他好文 时间:
2019-07-03 10:32:12
阅读次数:
73
一个prev保存前一个状态,一个cur保存这次的状态每次按题意操作prev,然后赋值给cur 如何按题意操作呢? 1 11 21 1211 111221 一个变量say保存到目前为止相同的值,直到say和prev[i]不同,就给cur插入say的个数,和say的值,然后更新say为prev[i] ...
分类:
其他好文 时间:
2019-06-03 12:45:55
阅读次数:
89
问题: 解决思路:从1到n,按照规则循环读取即可 Python代码: ...
分类:
其他好文 时间:
2019-05-01 13:48:48
阅读次数:
126
1. 38. Count and Say 就是对于前一个数,找出相同元素的个数,把个数和该元素存到新的string里。数量+字符 2. 58. Length of Last Word String.lastIndexOf(); 3. 100. Same Tree 采用递归的方法,return中逻辑的 ...
分类:
其他好文 时间:
2019-04-28 12:37:22
阅读次数:
97
[toc] 题目链接 " Count and Say LeetCode" 注意点 输入的序列可能小于等于0 解法 解法一:观察题目给的序列,加上网上的评论,可以看出从第二个序列开始,每个序列是对前一个序列的报数。例如,前一个序列是1211,那下一个序列就是1个1、1个2、2个1 = 111221。也 ...
分类:
其他好文 时间:
2019-02-05 09:26:19
阅读次数:
150
The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is read off as "two 1 ...
分类:
其他好文 时间:
2019-02-03 18:08:59
阅读次数:
177
The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is read off as "two 1 ...
分类:
其他好文 时间:
2019-01-30 00:12:51
阅读次数:
143
乘风破浪:LeetCode真题_038_Count and Say ...
分类:
其他好文 时间:
2019-01-05 15:45:16
阅读次数:
185
题解 题目大意是找第 n 个数(字符串表示),规则则是对于连续字符串,表示为重复次数+数本身。 后一个数等于前一个数的计数(字符串表示),有点类似斐波那契数列 JAVA: 源码分析 字符串是动态生成的,故使用 StringBuilder 更为合适。注意s 初始化为"1", 第一重 for循环中注意循 ...
分类:
其他好文 时间:
2018-12-06 17:55:36
阅读次数:
115