class Solution {
public:
int longestSubstringWithoutDuplication(string s) {
int maxv = 0;
int i = 0, j = 0;
bool st[30];
while(i <= j && j < s.size()){
while(j < s.size() && !st[s[j] - 'a']){
st[s[j] - 'a'] = true;
j ++ ;
}
maxv = max(maxv, j - i);
if(j == s.size()) break;
char t = s[j];
while(i <= j && s[i] != t){
st[s[i] - 'a'] = false;
i ++ ;
}
st[s[i ++ ] - 'a'] = false;
}
return maxv;
}
};