Advertisement
Josif_tepe

Untitled

Feb 6th, 2023
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main()
  10. {
  11.     string k;
  12.     cin>>k;
  13.     int len=k.size();
  14.     map<char, int>mapa;
  15.    
  16.     int current_len=0;
  17.     int max_len=0;
  18.     int j = 0;
  19.     int i =0 ;
  20.     while(j < len) {
  21.        
  22.         if(mapa[k[j]] == 0){
  23.                 mapa[k[j]]++;
  24.                 current_len++;
  25.                 max_len=max(max_len, current_len);
  26.                 j++;
  27.            
  28.         }
  29.         else{
  30.             mapa[k[i]]--;
  31.             current_len--;
  32.             i++;
  33.            
  34.         }
  35.     }
  36.  
  37.     cout<<max_len;
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement