Ctrl K

The Best Triple Digit Run

Easy
You are given a string digits made of digits. Look for every spot where the same digit appears three times in a row, and return the largest such triple as a three-character string, for example "777". Triples are compared as numbers, and "000" is allowed. If there is no triple at all, return the empty string "".
Example 1
digits="5222915558" → '555'

Both "222" and "555" fit; the larger one is "555".

Example 2
digits="70004" → '000'

The only triple is "000". Leading zeros are fine.

Example 3
digits="1122334" → ''

No digit appears three times in a row, so the answer is empty.

Constraints
  • 3 ≤ len(digits) ≤ 1000
  • digits contains only digits
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
digits="5222915558"
Expected
'555'

Run checks the first 3 tests in your browser. Submit checks all 136 tests on the server, hidden ones included.