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 wrak
#def zeros(line):
def non_repeat(line):
n=[]
o=""
u=""
n=[0]*140
t = []
s=""
if len(line)==1:
u=u+line
else:
for y in line:
for x in line:
t.append(x)
if n[ord(x)]==0:
#n.insert(ord(x), x)
n[ord(x)]=x
s=s+x
else:
if len(s)>len(u):
u=s
s=""
s=s+x
n.insert(ord(x), x)
n=[0]*140
s=""
s=s+x
n[ord(x)]=x
for p in t:
t.remove(p)
if len(s)>len(o):
o=s
n=[0]*140
s=""
line = line[:0]+ line[1:]
if len(o)>len(u):
u=o
return u
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"?')
"""#def zeros(line):
def non_repeat(line):
n=[]
u=""
for x in range(140):
n.insert(0, 0)
t = []
s=""
if len(line)==1:
u=u+line
else:
for x in line:
t.append(x)
if n[ord(x)]==0:
n.insert(ord(x), x)
s=s+x
else:
if len(s)>len(u):
u=s
s=""
s=s+x
n.insert(ord(x), x)
for o in range(140):
n[o]=0
s=""
s=s+x
n.insert(ord(x), x)
if len(s)>len(u):
u=s
return u
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"?')
"""
Oct. 19, 2017
Comments: