def get_longest_non_repeat_v2(string):
if string is None:<EOL><INDENT>return <NUM_LIT:0>, '<STR_LIT>'<EOL><DEDENT>sub_string = '<STR_LIT>'<EOL>start, max_len = <NUM_LIT:0>, <NUM_LIT:0><EOL>used_char = {}<EOL>for index, char in enumerate(string):<EOL><INDENT>if char in used_char and start <= used_char[char]:<EOL><INDENT>start = used_char[char] + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>if index - start + <NUM_LIT:1> > max_len:<EOL><INDENT>max_len = index - start + <NUM_LIT:1><EOL>sub_string = string[start: index + <NUM_LIT:1>]<EOL><DEDENT><DEDENT>used_char[char] = index<EOL><DEDENT>return max_len, sub_string<EOL>
Find the length of the longest substring
without repeating characters.
Uses alternative algorithm.
Return max_len and the substring as a tuple