#C2293. Transform To Palindrome
Transform To Palindrome
Transform To Palindrome
You are given a string s. You are allowed to reverse any non-empty substring any number of times. Determine whether it is possible to transform s into a palindrome. Of course, a palindrome is a string that reads the same forwards and backwards.
Hint: A string can be rearranged into a palindrome if and only if at most one character appears an odd number of times. In mathematical notation, if the frequency of each character in s is given by \(f(c)\), the condition is:
\[ \sum_{c \in s} \mathbb{1}_{\{f(c) \; \text{is odd}\}} \leq 1 \]It is guaranteed that the actions allowed are sufficient to achieve any reordering needed to satisfy the condition.
inputFormat
The first line of input contains an integer \(T\) (\(1 \leq T \leq 10^5\)), the number of test cases. Each of the following \(T\) lines contains a non-empty string \(s\) consisting of lowercase letters.
Please use standard input (stdin) to read the data.
outputFormat
For each test case, output a single line containing Yes
if it is possible to transform the given string into a palindrome using the allowed operations; otherwise, output No
.
Please use standard output (stdout) to print your results.
## sample2
abba
abc
Yes
No
</p>