class Solution {
public:
int lengthOfLongestSubstring(string s) {
string res = "";
int maxLen = 0;
// 1、双指针i,j
int i = 0;
int j = 0;
while (j < s.length()) {
while (j < s.length() && (res.find(s[j]) == string::npos )) {
res += s[j];
j ++;
}
maxLen = max(j - i, maxLen);
res = "";
i ++;
j = i;
}
return maxLen;
}
};