Question
Given a stringÂ
s, find the length of the longest substring without repeating characters.
This is a sliding_window question.
Idea
- Define a set for O(1) look up
- Iterate through the string (while r < len(s))
- If our char at
ris inseen, we want to remove our char atlfromseenand increment it WHILE the duplicate char is still in ourseenset - Otherwise, add
s[r]to seen, incrementrand compute new max