原题链接
Note:所有的双指针问题,优化就是想一想有没有单调性
class Solution {
public:
int lengthOfLongestSubstring(string s) {
unordered_map heap;
int res = 0;
for(int i = 0, j = 0; i < s.size(); i ++){
heap[s[i]] ++;
while(heap[s[i]] > 1) heap[s[j ++]] --;
res = max(res, i - j + 1);
}
return res;
}
};



