Generate the n-th term of the count-and-say sequence by repeatedly describing the previous term.
The count-and-say sequence is defined by repeatedly reading the previous term and encoding consecutive identical digits as:
Start with 1 as the first term.
Your task is to return the n-th term of this sequence.
111 → one 121 → two 1s1211 → one 2, then one 1Build the sequence until you reach the requested term and return it as a string.
n representing the term to generate.n-th string in the count-and-say sequence.1 <= n is assumed.Example 1
Input
n = 1
Output
"1"
Explanation
The first term of the sequence is defined to be 1.
Example 2
Input
n = 4
Output
"1211"
Explanation
The sequence is: 1, 11, 21, 1211. The 4th term is 1211.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.