class Solution {
public:
int lengthOfLongestSubstring(string s) {
vector<int> lenv(s.size(),1);
vector<int> hashv(200,0);
int lasti=0;
hashv[(int)s[0]] = 1;
for(int i=1;i<s.size();i++)
{
// int j = 0;
if (hashv[(int)s[i]]==0)
{
lenv[i] = lenv[i-1] + 1;
hashv[(int)s[i]] = 1;
}
else
{
for(int j=lasti;j<i;j++)
{
hashv[(int)s[j]] = 0;
if(s[j]==s[i])
{
lenv[i] = i - j;
lasti = j + 1;
break;
}
// return j;
}
hashv[(int)s[i]] = 1;
}
}
int maxs = 0;
for(int i;i<lenv.size();i++)
{
if(maxs<lenv[i])
{
maxs = lenv[i];
}
}
return maxs;
}
};