The count-and-say sequence starts with "1". Each later term describes the previous one out loud: split it into runs of equal digits, and for each run write how many digits it has followed by the digit. For example "3322251" reads as two 3s, three 2s, one 5, one 1, giving "23321511". Given n, return the nth term.
The count-and-say sequence starts with "1". Each later term describes the previous one out loud: split it into runs of equal digits, and for each run write how many digits it has followed by the digit. For example "3322251" reads as two 3s, three 2s, one 5, one 1, giving "23321511". Given n, return the nth term.
Example 1:
Input: {"n":4}
Output: 1211
Constraints:
1≤n≤30
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":4}
Term 1 is "1". Each pass reads the current term aloud to build the next one.