digits made of digits.
Call two equal digits standing next to each other a double. For example, "7337" has one double (33), "1220055" has three (22, 00, 55), and "5555" has three as well, since each neighbouring pair counts separately.
Return the length of the longest contiguous piece of digits that contains at most one double.digits="3445667" → 5
The whole string has two doubles, 44 and 66. The piece "34456" contains only 44 and has length 5; so does "45667".
digits="9080" → 4
There are no equal neighbouring digits at all, so the whole string works.
digits="000" → 2
"000" contains two pairs of neighbouring zeros while "00" has one, so the answer is 2.
digits consists of digits 0 to 9digits="3445667"
5
Run checks the first 3 tests in your browser. Submit checks all 200 tests on the server, hidden ones included.