3. 无重复字符的最长子串 - 力扣(LeetCode)
class Solution:def lengthOfLongestSubstring(self, s: str) -> int:char_set = set()left = 0max_length = 0for right in range(len(s)):while s[right] in char_set:char_set.remove(s[left])left += 1char_set.add(s[right])max_length = max(max_length, right - left + 1)return max_length