Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Non Repeat by Oleg_Levonjuk
def non_repeat(line):
"""
the longest substring without repeating chars
"""
for i in range(len(line), 0, -1):
for j in range(len(line)-i+1):
substr = line[j:j+i]
if len(set(substr)) == len(substr):
return substr
return ''
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"?')
April 12, 2020
Comments: