-
Notifications
You must be signed in to change notification settings - Fork 303
Open
Labels
@tech-cow
Description
globalSet这块看了下答案,没完全写对,再刷一次
class Solution(object): def lengthOfLongestSubstring(self, s): globalMax = -float('inf') globalSet = set() j = 0 for i in range(len(s)): while j < len(s) and s[j] not in globalSet: globalSet.add(s[j]) globalMax = max(globalMax, len(globalSet)) j += 1 globalSet.remove(s[i]) return globalMax if globalMax != -float('inf') else 0