fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string a;
  7. cin>>a;
  8. set<char>st;
  9. int end,start=0,mxl=INT_MIN;
  10. for(end=0;end<a.length();end++)
  11. {
  12. while(st.find(a[end])!=st.end())
  13. {
  14. st.erase(a[start]);
  15. start++;
  16. }
  17. st.insert(a[end]);
  18. mxl=max(mxl,end-start+1);
  19.  
  20. }
  21. cout<<mxl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 4472KB
stdin
ABCEBDABC
stdout
5