```
class Solution {
public:
int lengthOfLongestSubstring(string s) {
int index[257] = {0};
for (int i = 0,j = 0; i < s.length();i ++) {
j = max(j, index[s[i]]);
index[s[i]] = i + 1;
index[256] = max(index[256],i - j + 1);
}
return index[256];
}
};
```