Josif_tepe

Untitled

Feb 11th, 2026
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     string str;
  7.     cin>>str;
  8.     map<char,int> m,check;
  9.     for(int i=0;i<str.size();i++)
  10.         m[str[i]]++;
  11.     int max_len=1;
  12.     for(int i=0;i<str.size();i++)
  13.     {
  14.         if(m[str[i]]>=2&&check[str[i]]==0)
  15.         {
  16.             if(m[str[i]]%2==0)
  17.                 max_len+=m[str[i]];
  18.             else
  19.                 max_len+=m[str[i]]-1;
  20.             m[str[i]]=0;
  21.             check[str[i]]++;
  22.         }
  23.     }
  24.     cout<<max_len;
  25.     return 0;
  26. }
  27.  
  28.  
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment