class Solution {
public:
/**
*
* @param s string字符串
* @return int整型
*/
int lengthOfLongestSubstring(string s) {
// write code here
map<char, int> mp;
int start =-1, ans =0;
for(int i=0;i<s.length();i++){
if(mp.count(s[i]))
start = max(start, mp[s[i]]);
mp[s[i]] = i;
ans = max(ans, i-start);
}
return ans;
}
};