MediumRating 1533
3. Longest Substring Without Repeating Characters
hash-tablestringsliding-window
解題說明
C++ 解法
複雜度分析
虛擬碼
1. left = 0, maxLen = 0, lastSeen = {}
2. For right from 0 to n-1:
a. If s[right] in lastSeen and lastSeen[s[right]] >= left:
left = lastSeen[s[right]] + 1
b. lastSeen[s[right]] = right
c. maxLen = max(maxLen, right - left + 1)
3. Return maxLen