Advertisement
sketkar

Minimised Operations- ICL2023

Mar 10th, 2023
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #include<bits/stdc++.h>
  4. int main() {
  5. // your code goes here
  6. int t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. int n;
  11. cin>>n;
  12. string input;cin>>input;
  13. int ans=1e9;
  14. for(int j=0;j<26;j++)
  15. {
  16. int curAns=0;
  17. for(int i=0;i<n;i++)
  18. {
  19. if(input[i]-'a'!=((j+i)%26))curAns++;
  20. }
  21. ans=min(ans,curAns);
  22. }
  23. cout<<ans<<endl;
  24.  
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement