Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple solution in Clear category for Long Non Repeat by Pouf
def non_repeat(line: str) -> str:
nb_char = len(line)
for length in reversed(range(1, nb_char + 1)):
for start in range(nb_char - length + 1):
if has_unique_elements(candidate := line[start:start + length]):
return candidate
return ""
def has_unique_elements(s: str) -> bool:
return len(set(s)) == len(s)
July 5, 2020
Comments: