Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
multi-initialization solution in Clear category for Long Repeat by joe_5588
def long_repeat(line: str) -> int:
if len(line) == 0:
return 0
repeats, max_repeats = 1, 1
for i in range(1, len(line)):
if line[i] == line[i - 1]:
repeats += 1
else:
repeats = 1
if repeats > max_repeats:
max_repeats = repeats
return max_repeats
Sept. 11, 2023
Comments: