Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Long Non Repeat by dshimbori
def non_repeat(line):
result = ''
letters = len(set([x for x in line]))
for j in range(letters):
for i in range(len(line)-j):
if len(result) < len(line[i:i+j+1]) and len(set([x for x in line[i:i+j+1]]))==len(line[i:i+j+1]):
result = line[i:i+j+1]
return result
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"?')
June 12, 2018