Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Repeat by Max0526
def long_repeat(line: str) -> int:
if len(line) <= 1:
return len(line)
prev = line[0:1]
c = 1
ma = 0
for i in range(1,len(line)):
if line[i] == prev:
c += 1
if c > ma:
ma = c
if line[i] != prev:
prev = line[i:i+1]
c = 1
return ma
print("Example:")
print(long_repeat("sdsffffse"))
assert long_repeat("sdsffffse") == 4
assert long_repeat("ddvvrwwwrggg") == 3
print("The mission is done! Click 'Check Solution' to earn rewards!")
May 3, 2023