1. Understand the problem

Given a string s, find the length of the longest substring that contains no repeated characters.

A substring is a contiguous sequence of characters.

Example 1:

s = "abcabcbb"

The longest substring without repeating characters is "abc".

String:  a  b  c  a  b  c  b  b
         └─────┘
         "abc"

Length = 3

Example 2:

s = "bbbbb"

The longest substring is "b", so the answer is 1.

Example 3:

s = "pwwkew"

The longest substring is "wke" or "kew", so the answer is 3.

Notice that "pwke" is not a valid substring because its characters aren't contiguous.

2. Key idea (Signal)

The key signal is substring + no repeating characters.

This suggests using the sliding window technique.

We maintain a window representing the current substring:

s = "abcabcbb"

       left
         ↓
s =     [a  b  c] a  b  c  b  b
         ↑        ↑
        left     right

We use two pointers: