#K3766. One-Removal Palindrome
One-Removal Palindrome
One-Removal Palindrome
You are given one or more strings composed of uppercase consonants. For each string, determine whether it can be transformed into a palindrome by removing at most one character.
A palindrome is a sequence of characters that reads the same forwards and backwards. In mathematical terms, a string \( s = s_1 s_2 \ldots s_n \) is a palindrome if \( s_i = s_{n-i+1} \) for every valid index \( i \).
Your task is to print Possible
if the string is already a palindrome or can become one by removing exactly one character, and Not Possible
otherwise.
Note: The removal of one character is optional if the string is already a palindrome.
inputFormat
The input is read from standard input (stdin) and has the following format:
T s1 s2 ... sT
Here, T
is an integer representing the number of test cases, followed by T
strings, one per line.
outputFormat
For each test case, output a single line on standard output (stdout) containing either Possible
or Not Possible
indicating whether the string can be converted into a palindrome by removing at most one character.
1
BCDCB
Possible
</p>