AmazonOA #248
Is Special Sequence
估计中等可在线判题
Cut a lowercase string into two non-empty contiguous substrings. From each part you may delete at most one character, then rearrange it freely; output YES if both parts can form palindromes, otherwise NO. Deleting is optional, and a part of length 1 can be kept as is.
输入格式
One line containing the string. 1≤length≤300000, lowercase letters.
输出格式
Output a single integer, the answer.
样例 1
输入:
abcad
输出:
YES
样例 2
输入:
abcde
输出:
NO
样例 3
输入:
a
输出:
NO
样例说明
The answers are YES, NO and NO. However abcde is split, one of the two parts has at least 3 characters that each occur once, so even after one deletion it cannot be rearranged into a palindrome.