Count and Say

Medium · Math & Number Theory · about 15 minutes

Asked at Google, Amazon, Meta, Bloomberg, Microsoft, JPMorgan Chase.

The count-and-say sequence starts with "1". Each next term reads the previous one aloud as runs of digits: "1" → one 1 → "11" → two 1s → "21" → one 2, one 1 → "1211", and so on. Return the n-th term.