Count and Say

Medium

The count-and-say sequence starts at "1". Each following term reads the previous one out loud: run lengths followed by the digit.

Given n, return the n-th term.

Example 1

countAndSay()
Input
n = 1
Output
"1"

Example 2

countAndSay()
Input
n = 4
Output
"1211"

Why

1 → 11 → 21 → 1211
Constraints
1 <= n <= 30

Topics

StringsRecursion

Implement countAndSay in the editor and return the answer — printing it is never graded.