------
## 最终结论
```python
def length_of_longest_substring(s: str) -> int:
    char_index = {}
    left_pointer = 0
    max_length = 0

    for right_pointer in range(len(s)):
        if s[right_pointer] in char_index and char_index[s[right_pointer]] >= left_pointer:
            left_pointer = char_index[s[right_pointer]] + 1

        char_index[s[right_pointer]] = right_pointer
        max_length = max(max_length, right_pointer - left_pointer + 1)

    return max_length
```