[v2] enumerate, try line.index, max(..., key=len) solution in Clear category for Long Non Repeat by Phil15
""" The longest substring without repeating chars. """
# Search the first repeating char.
for i1, ch in enumerate(line):
# We search the first two indexes (i1 and i2) of ch in the line.
i2 = line.index(ch, i1 + 1)
# The solution is before i2 or strictly after i1.
return max(non_repeat(line[:i2]), non_repeat(line[i1 + 1:]), key=len)
return line # No repeating char here so it's the entire line.
March 27, 2019