Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Repeat by tony-aycc
def long_repeat(line: str) -> int:
"""
length the longest substring that consists of the same char
"""
word = ''
result = []
for i in line:
if i == word:
result[-1] = result[-1] +1
else:
result.append(1)
word = i
return max(result) if len(result) > 0 else 0
print(long_repeat('sdsffffse'))
print(long_repeat(''))
March 6, 2020