标签:problems ++ public hang char order 试题 -- solution
链接:https://leetcode-cn.com/problems/zui-chang-bu-han-zhong-fu-zi-fu-de-zi-zi-fu-chuan-lcof/
class Solution {
public:
int lengthOfLongestSubstring(string s) {
unordered_map<char, int> count;
int res = 0;
for (int i = 0, j = 0; j < s.size(); ++j) {
if (++count[s[j]] > 1) {
while (count[s[i]] == 1) count[s[i++]]--;
count[s[i++]]--;
}
res = max(res, j - i + 1);
}
return res;
}
};
剑指OFFER----面试题48. 最长不含重复字符的子字符串
标签:problems ++ public hang char order 试题 -- solution
原文地址:https://www.cnblogs.com/clown9804/p/12436392.html