-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathTheLove-LetterMystery.java
More file actions
25 lines (24 loc) 路 774 Bytes
/
Copy pathTheLove-LetterMystery.java
File metadata and controls
25 lines (24 loc) 路 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;
public class Solution {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n!=0){
int count = 0;
char[] a = sc.next().toCharArray();
int l = a.length;
for(int i=0;i<l/2;i++){
if((int)a[i]>(int)a[l-1-i]){
count = count + (int)a[i]-(int)a[l-1-i];
a[i] = a[l-1-i];
}
else if((int)a[i]<(int)a[l-1-i]){
count = count + (int)a[l-1-i]-(int)a[i];
a[l-1-i] = a[i];
}
}
System.out.println(count);
n--;
}
}
}