Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def lengthOfLongestSubstring(self, s: str) -> int:
- l = 0
- r = 0
- memo = set()
- res = 0
- while r < len(s):
- if s[r] not in memo:
- memo.add(s[r])
- r += 1
- res = max(res, r - l)
- else:
- memo.remove(s[l])
- l += 1
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement