Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include<bits/stdc++.h>
- int main() {
- // your code goes here
- int t;
- cin>>t;
- while(t--)
- {
- int n;
- cin>>n;
- string input;cin>>input;
- int ans=1e9;
- for(int j=0;j<26;j++)
- {
- int curAns=0;
- for(int i=0;i<n;i++)
- {
- if(input[i]-'a'!=((j+i)%26))curAns++;
- }
- ans=min(ans,curAns);
- }
- cout<<ans<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement