No.1617 Palindrome Removal
Problem Statement
Among the strings that are not palindromes and can be obtained by removing an even number of characters from the string $S$, find the length of the longest one.
Input
$S$
- $1\leq |S|\leq 10^6$
- $S$ consists of lowercase English letters
Output
Output the answer on one line. If no non-palindromic string can be obtained, output -1 instead.
Sample
Sample 1
Input
aaabbbaaa
Output
7
For example, removing the a at position $3$ and the b at position $4$ gives aabbaaa, which is not a palindrome.
Sample 2
Input
abc
Output
3
The string is not a palindrome to begin with.
Sample 3
Input
aaaa
Output
0
The empty string is not considered a palindrome.
Sample 4
Input
z
Output
-1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
だれ
nok0