class Solution {
public:
int lengthOfLongestSubstring(string s) {
vector<int>v(256,-1);
int len = s.size();
int ans = 0;
int start = -1;
for(int i=0; i<len; i++)
{
int a = s[i];
if(start < v[a])
{
start = v[a];
}
v[a] = i;
ans = max(ans,i-start);
}
return ans;
}
};