A ceramics workshop stamps every kiln load with a batch code made only of decimal digits. Inspectors watch for a "triple mark": three consecutive positions in the code that show the exact same digit, which signals a fully cured load. Given the batch code, find the triple mark built from the largest possible digit. If several triple marks appear in the code, only the repeated digit's value matters (a triple mark is always written as that digit three times, e.g. digit 7 gives "777"), so report the one using the greatest digit. If the code contains no run of three identical digits anywhere, report that none was found.
A single line containing the batch code: a nonempty string of decimal digits.
Print the largest triple mark as a 3-character string of the repeated digit (for example "777"). If no triple mark exists anywhere in the code, print an empty line.
Example 1
Input
6777133339
Expected
777
Explanation
Scanning the code, indices 1-3 hold "777" and indices 5-7 hold "333" (0-indexed). Both are triple marks; since digit 7 is larger than digit 3, the workshop reports "777".
Example 2
Input
2300019
Expected
000
Explanation
The only run of three identical digits is "000" starting at index 1. No larger triple mark exists anywhere else in the code, so the answer is "000".
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →