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.
Note: The sequence of integers will be represented as a string.
1.思路:题目中所有的结果都是递推得到,则首先想到两种方法:队列,递归。
我使用了前者实现。因为不知道数字的规模,如果贸然使用递归可能会造成overstack
首先,在......
阅读全文