-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ03025.java
More file actions
38 lines (34 loc) · 915 Bytes
/
J03025.java
File metadata and controls
38 lines (34 loc) · 915 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
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.*;
import java.math.*;
public class J03025 {
public static boolean check(String s) {
int l = 0;
int r = s.length() - 1;
int cnt = 0;
while (l <= r) {
if (s.charAt(l) != s.charAt(r)) {
cnt++;
}
l++;
r--;
}
if ((s.length() % 2 == 0 && cnt == 1) || (s.length() % 2 == 1 && cnt <= 1)) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
while (n-- > 0) {
String s = sc.nextLine();
if (check(s)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}