Open Shuai-Lou opened 1 year ago
Longest Substring Without Repeating Characters
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: if not s: return 0 nb = [] max_len = 0 for i in s: while i in nb: del nb[0] nb.append(i) if len(nb) > max_len: max_len = len(nb) return max_len