Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Repeat by siemennooren
def long_repeat(str) -> int:
count = 0
temp = 0
if len(str)==0:
return 0
previous = str[0]
for x in str:
if x ==previous:
temp+=1
else:
previous = x
temp = 1
if temp>count:
count = temp
return count
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert long_repeat('sdsffffse') == 4, "First"
assert long_repeat('ddvvrwwwrggg') == 3, "Second"
assert long_repeat('abababaab') == 2, "Third"
assert long_repeat('') == 0, "Empty"
print('"Run" is good. How is "Check"?')
March 4, 2020