Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
With auxiliary function solution in Clear category for Long Non Repeat by dbirmajer
def non_repeat(line):
"""
the longest substring without repeating chars
"""
def _non_repeat(line=""):
chrs = set()
for chr in line:
if not chr in chrs:
chrs.add(chr)
else:
return line[:len(chrs)]
return line
return max((_non_repeat(line[i:]) for i in range(len(line))), key=len, default="")
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert non_repeat('aaaaa') == 'a', "First"
assert non_repeat('abdjwawk') == 'abdjw', "Second"
assert non_repeat('abcabcffab') == 'abcf', "Third"
print('"Run" is good. How is "Check"?')
Jan. 3, 2022