The count-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, ...
Given an integer n, generate the nth sequence.
Note: The sequence of integers will be represented as a string.
<Solution>這邊再多看一個 output ,會比較知道說什麼
n = 6,"312211"
可以知道,就是去看同樣的字元有幾個,然後把計數加該字元放到下一個string
code 如下
C++
Java
Kotlin
沒有留言:
張貼留言