Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
O(n) solution in Speedy category for Long Repeat by Sim0000
def long_repeat(line):
maxv = count = 0
last = None
for c in line:
if c == last:
count += 1
else:
maxv = max(maxv, count)
count = 1
last = c
return max(maxv, 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"
print('"Run" is good. How is "Check"?')
March 25, 2018
Comments: