class Solution {
boolean[] alpha = new boolean[257];
public void resetAlpha(){
for (int i = 0; i < 257; i ++){
alpha[i] = false;
}
}
public int lengthOfLongestSubstring(String s) {
resetAlpha();
int maxLength = 0, tLength = 0;
int p = 0;
for (int i = 0; i < s.length(); i ++){
if (alpha[s.charAt(i)] == false){
alpha[s.charAt(i)] = true;
tLength += 1;
}
else{
if (tLength > maxLength){
maxLength = tLength;
}
resetAlpha();
tLength = 1;
alpha[s.charAt(i)] = true;
for (int j = -1; j > - 24; j --){
if(s.charAt(i + j) != s.charAt(i)){
alpha[s.charAt(i + j)] = true;
tLength += 1;
}
else
break;
}
}
}
if (tLength > maxLength){
maxLength = tLength;
}
return maxLength;
}
}