Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
KMP inverted solution in Clear category for Long Non Repeat by veky
def intervals(line):
last = {}
start = end = 0
for i, letter in enumerate(line):
end += 1
if letter in last and start <= last[letter]:
start = last[letter] + 1
yield line[start:end]
last[letter] = i
def non_repeat(line):
return max(intervals(line), key=len, default='')
Aug. 12, 2017
Comments: