Created
April 11, 2024 23:10
-
-
Save jesuscmadrigal/adec6c63b2855527394540a48adc3cc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def lengthOfLongestSubstring(self, s: str) -> int: | |
left, maxSub, seen = 0, 0, set() | |
for right in range(len(s)): | |
while s[right] in seen: | |
seen.remove(s[left]) | |
left += 1 | |
seen.add(s[right]) | |
maxSub = max(maxSub, (right - left) + 1) | |
return maxSub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment