Practice · 4 of 6
Longest Digit Run
CHALLENGE
Difficulty: intermediate+25 XP
**Description:** Given a positive integer n, find the length of the
longest run of equal consecutive digits (in normal left-to-right order).
**Input:** One integer n (1 ≤ n ≤ 10^18).
**Output:** One integer — the longest run length.
**Example:** 1223331 → the run 333 has length 3.
*Note:* digits arrive right-to-left from % 10 — track the current run
carefully as digits change.
Press Submit to check your solution.
Back to lesson: Practice: Loop Patterns Set