class Solution {
public:
int lengthOfLongestSubstring(string s) {
if(s.size()==0) return 0;
unordered_map<char,int> window;
int left=0,right=0;
int maxLength=0;
while(right<s.size()){
char c=s[right];
right++;
window[c]++;
while(window[c]>1){
window[s[left]]--;
left++;
}
maxLength=max(maxLength,right-left);
}
return maxLength;
}
};