Advertisement
Promi_38

cf 1552A

Sep 25th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include<bits\stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t;
  8.     scanf("%d", &t);
  9.     while(t--)
  10.     {
  11.         int n;
  12.         scanf("%d", &n);
  13.         string s;
  14.         cin >> s;
  15.         string s1 = s;
  16.         sort(s1.begin(), s1.end());
  17.        //cout << s << s1;
  18.         int cnt = 0;
  19.         for(int i = 0; i < n; i++)
  20.         {
  21.             if(s[i] != s1[i]) cnt++;   
  22.         }
  23.         printf("%d\n", cnt);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement