You are viewing a single comment's thread. Return to all comments →
#include<bits/stdc++.h> using namespace std; int main() { int n ; cin>>n ; for(int k = 0 ; k< n ; ++k) { string s1 ; cin>>s1 ; int i = 0 ; int j = s1.length() - 1 ; int ans = 0 ; while(i <= j ) { int max1 = max((int)s1[i],(int)s1[j]) ; int min1 = min ((int)s1[i],(int)s1[j]) ; ans += (max1 - min1) ; i++; j--; } cout<<ans<<"\n" ; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
The Love-Letter Mystery
You are viewing a single comment's thread. Return to all comments →