We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
The text was updated successfully, but these errors were encountered:
class Solution(object): def lengthOfLongestSubstring(self, s): maxLen = 0 visited = set() n = len(s) i, j = 0, 0 while i < n and j < n: if s[j] not in visited: visited.add(s[j]) maxLen = max(maxLen, j - i + 1) j += 1 else: visited.remove(s[i]) i += 1 return maxLen
Sorry, something went wrong.
No branches or pull requests
globalSet这块看了下答案,没完全写对,再刷一次
The text was updated successfully, but these errors were encountered: