Maintain a sliding window with no duplicate characters.
Track the last index where each character was seen. Move the left boundary l forward when a duplicate appears inside the window.
The window [l..r] is always kept duplicate-free; each index advances monotonically, giving linear time.
Maintain a sliding window with no duplicate characters.
Track the last index where each character was seen. Move the left boundary l forward when a duplicate appears inside the window.
The window [l..r] is always kept duplicate-free; each index advances monotonically, giving linear time.