问题
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 _n_th sequence.
Note: The sequence of integers will be represented as a string.
翻译
数数问题是像如下顺序的整数:
1, 11, 21, 1211, 111221, ...
1
被读作 "1个1"
或者 11
。
11
被读作2个1
或者21
。
21
被读作1个2
,然后1个1
或者1211
。
给出整数 n_, 求出第 _n 个结果。
进一步解释:
1
念作11
, 11
念作21
, 21
念作1211
…
求出第 _n _个念作什么。
解决方法
1 | func countAndSay(n int) string { |