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.
package pack;
class Solution {
public String countAndSay(int n) {
if(n == 0)
return null;
String
LeetCode数说序列生成

本文介绍了LeetCode中Count and Say问题的解决方法,详细解析了数说序列的生成过程,例如1 -> 11 -> 21 -> 1211 -> 111221,并给出如何根据给定整数n生成数说序列的思路。
订阅专栏 解锁全文
844

被折叠的 条评论
为什么被折叠?



