Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Long Non Repeat by Rounin
def isUnique(line):
found = {}
for c in list(line):
if c in found:
return False
found[c] = True
return True
def non_repeat(line):
for length in range(0, len(line)+1)[::-1]:
for start in range(len(line)+1-length):
if(isUnique(line[start:start+length])):
return line[start:start+length]
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"?')
Sept. 28, 2017