Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple recursion solution in Clear category for Long Non Repeat by hanpari
def non_repeat(line):
return (line if len(line) == len(set(line)) else
max(non_repeat(line[:-1]),
non_repeat(line[1:]), key=len)
)
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"?')
Aug. 15, 2017
Comments: