Practice Count and Say
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Start with countAndSay(1) = "1". Each later term describes consecutive equal-digit runs in the previous term: write the run length followed by its digit, preserving run order. Return the nth term as a string. Separated runs of the same digit must stay separate. Practice approach: Build terms iteratively. Scan the current string with a start pointer and advance until the digit changes, then append the count and digit. Use a fresh output buffer per term. Runtime is proportional to the total characters examined across terms, and space to the largest current term.
Source: Count and Say on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 5
"111221"
The terms begin 1, 11, 21, 1211, 111221. The last step reads one 1, one 2, and two 1s.
Constraints
Related LeetCode Problems
Practice more problems similar to Count and Say.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.