Source Code
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
int main()
{
  string s,alpha="abcdefghijklmnopqrtuvwxyz";cin>>s;
  int ans=INT_MAX,temp=0;
  for(int i=0;i<26;i++)
  {
    temp=0;
    for(int j=0;j<s.size();j++)temp+=abs(s[j]-alpha[i]);
    ans=min(ans,temp);
  }
  cout<<ans<<"\n";
}
Copy
Palindrome Substrings 3am0rab1
GNU G++17
3 ms
844 KB
Wrong Answer