Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Very Clear (but not the more efficient) solution in Clear category for Long Non Repeat by bsquare
def non_repeat(line):
substrings = []
for available_substring in [line[start:] for start in range(0, len(line))]:
current_substring = ''
for item in available_substring:
if item in current_substring:
break
current_substring += item
if current_substring not in substrings:
substrings += [current_substring]
return max(substrings, 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"?')
Sept. 2, 2019
Comments: