classSolution { public: intlengthOfLongestSubstring(string s){ int right = 0, left = 0, ans = 0, l = s.size(); for(; right < l; ++right){ for(int i = left; i < right; ++i){ if(s[i] == s[right]){ left = i + 1; break; } } ans = max(ans, right - left + 1); } return ans; } };