def longest_non_repeat_v2(string):
    """
    Find the length of the longest substring
    without repeating characters.
    Uses alternative algorithm.
    """
    if string is None:
        return 0
    start, max_len = 0, 0
    used_char = {}
    for index, char in enumerate(string):
        if char in used_char and start <= used_char[char]:
            start = used_char[char] + 1
        else:
            max_len = max(max_len, index - start + 1)
        used_char[char] = index
    return max_len
def longest_non_repeat_v2 ( string ) : if string is None : return 0 start , max_len = 0 , 0 used_char = { } for index , char in enumerate ( string ) : if char in used_char and start <= used_char [ char ] : start = used_char [ char ] + 1 else : max_len = max ( max_len , index - start + 1 ) used_char [ char ] = index return max_len
Find the length of the longest substring
    without repeating characters.
    Uses alternative algorithm.