[LeetCode] Count and Say, Solution
2016-01-12 11:10
295 查看
The count-and-say sequence is the sequence of integers beginning as follows:
Given an integer n[/i], generate the n[/i]th sequence.
Note: The sequence of integers will be represented as a string.
» Solve this problem
[Thoughts]
string-operation. The only trick thing is Line11. seq[seq.size()] always ‘
1, 11, 21, 1211, 111221, ...
1is read off as
"one 1"or
11.
11is read off as
"two 1s"or
21.
21is read off as
"one 2, then
one 1"or
1211.
Given an integer n[/i], generate the n[/i]th sequence.
Note: The sequence of integers will be represented as a string.
» Solve this problem
[Thoughts]
string-operation. The only trick thing is Line11. seq[seq.size()] always ‘