Decode the Pattern (Look-and-Say Sequence)
Hard
string
simulation
pattern
iteration
Problem Description
Generate the nth term of the "look-and-say" sequence. The sequence starts with "1" and each subsequent term describes the previous term by counting consecutive identical digits.
Input Format
A single integer n (1-indexed position in sequence).
Output Format
The nth term of the look-and-say sequence as a string.
Constraints
• 1 ≤ n ≤ 30
• Sequence starts with "1" as the first term
• Each term describes the count and digit of consecutive groups
• Return result as a string
Sample Input/Output
Input:
4
Output:
1211
Explanation
Sequence: 1st="1", 2nd="11" (one 1), 3rd="21" (two 1s), 4th="1211" (one 2, one 1). The 4th term is "1211".
Solution Hints
110
Points
Points
3000ms
Time Limit
Time Limit
256MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now