class Solution {
public:
int lengthOfLongestSubstring(string s) {
unordered_set<char> uod_set;
int n = s.size();
int count = 0;
int length = 0;
int l_point, r_point = 0;
for(l_point = 0; l_point < n; l_point++){
while(!uod_set.count(s[r_point]) && r_point < n){
uod_set.insert(s[r_point]);
r_point++;
}
length = r_point - l_point;
if(length > count)
count = length;
uod_set.erase(s[l_point]);
}
return count;
}
};
11-04
03-09
11-17
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交