mirror of
https://github.com/prdlk/leetcode.git
synced 2026-09-16 23:16:26 +00:00
feat(work): add longest‑repeating‑character‑replacement solution and rename variable in longest‑substring solution
This commit is contained in:
@@ -45,12 +45,12 @@ class Solution:
|
||||
def lengthOfLongestSubstring(self, s: str) -> int:
|
||||
left = 0
|
||||
ans = 0
|
||||
seen = set()
|
||||
window = set()
|
||||
for right, c in enumerate(s):
|
||||
while c in seen:
|
||||
seen.remove(s[left])
|
||||
while c in window:
|
||||
window.remove(s[left])
|
||||
left += 1
|
||||
seen.add(c)
|
||||
window.add(c)
|
||||
ans = max(ans, right - left + 1)
|
||||
|
||||
return ans
|
||||
|
||||
Reference in New Issue
Block a user