int Solution::lengthOfLongestSubstring(string A) {
unordered_set<char> s;
int begin = -1;
int end = -1;
int maxLength = 0;
for(const char &ch: A) {
while(s.find(ch) != s.end()) {
begin++;
s.erase(A[begin]);
}
end++;
s.insert(A[end]);
maxLength = max(maxLength, end - begin);
}
return maxLength;
}