Mike and palindrome
time limit per test 2 second memory limit per test 256 megabytes
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.

A palindrome is a string that reads the same backward as forward, for example strings “z”, “aaa”, “aba”, “abccba” are palindromes, but strings “codeforces”, “reality”, “ab” are not.

传送门:CF798A

Input

The first and single line contains string s (1≤|s|≤15).

Output

Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.

Sample Input

1
abccaa

Sample Output

1
YES

题解

这里的回文串是必须替换一个字符是否能形成回文 那么头和尾双指针扫一遍,如果不同处只有1处,那就可以 还有一种情况,那就是没有不同处,但字符串的长度是奇数,那么可以改中间那个字符达成。
## AC code:(不包含输入类)
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
39
40
41
import java.util.*;  

public class Main {

public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
while (sc.hasNext()) {
String s = sc.next();
boolean flag = false;
if (judge(s)) {
flag = true;

}
if (flag)
pw.println("YES");
else
pw.println("NO");
pw.flush();
}
}

static boolean judge(String s) {
int start = 0;
int end = s.length() - 1;
int count = 0;
while (start < end) {
if (s.charAt(start) != s.charAt(end)) {
count++;
}
start++;
end--;
}
if (count == 1)
return true;
else if(count==0&&s.length()%2!=0)
return true;
else
return false;
}
}