Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Repeat by imloafer
from itertools import groupby
def long_repeat(line: str) -> int:
"""
length the longest substring that consists of the same char
"""
# your code here
return max(sum(1 for i in g) for k, g in groupby(line)) if line else 0
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. 17, 2022
Comments: