Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Repeat by diwert-ai
def long_repeat(line: str) -> int:
i, res, n = 0, 0, len(line)
while i < n:
j = i
while j < n and line[j] == line[i]:
j += 1
res = max(res, j - i)
i = j
return res
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!")
Oct. 9, 2022
Comments: