Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Repeat by rybld2
def long_repeat(line: str) -> int:
"""
length the longest substring that consists of the same char
"""
champion = len(line)
if champion:
i = 1
champion = 1
while i < len(line):
j, cpt = i, 1
while j < len(line) and line[j - 1] == line[j]:
j += 1
cpt += 1
if cpt > champion:
champion = cpt
i = j + 1
return champion
Jan. 2, 2021
Comments: