Ankit_132

A

Dec 19th, 2023
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7.  
  8. int main()
  9. {
  10.     _test
  11.     {
  12.         int n;
  13.         string s;
  14.         cin>>n>>s;
  15.  
  16.         int ans=0, x=1;
  17.  
  18.         for(char ch='A'; ch<='Z'; ch++)
  19.         {
  20.             ans += (count(s.begin(), s.end(), ch) >= x);
  21.             x++;
  22.         }
  23.  
  24.         cout<<ans<<"\n";
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment