01 · Question
Given a string s, find the length of the longest substring without repeating characters.
s
02 · Solution
1def lengthOfLongestSubstring(s: str) -> int:2 seen = {}3 l = 04 res = 05 6 for r in range(len(s)):7 if s[r] in seen and seen[s[r]] >= l:8 l = seen[s[r]] + 19 seen[s[r]] = r10 res = max(res, r - l + 1)11 12 return res