All Tracks Algorithms Greedy Algorithms Basics of Greedy Algorithms Problem

One Swap to Palindrome
/

Algorithms, Greedy Algorithms, Implementation, String Manipulation

Problem
Editorial
Analytics

You are given T tasks to perform. In each task, you are given a string S of length N. You are allowed to select any two indices i and j (i!=j) of the given string and perform exactly one swap between the characters at these indices.

If it is possible to make the new string a palindrome then print "Yes", else print "No".

Note:

A string is said to be palindrome if it reads same as its reverse form. For example: "madam" , "dad" etc.

 

INPUT

First line contain an integer T denoting total number of tasks to perform.

Each of the following T lines contains a string S.

 

OUTPUT

For each task, print a single line with "Yes" if it is possible to make palindrome otherwise print "No" without any quotes.

 

Constraints:

\(1 \le T \le 5\)
\(2 \le N \le 100000\)

String contains only lowercase English alphabets.

SAMPLE INPUT
1
bbg

SAMPLE OUTPUT
Yes
Explanation

We can swap indices pair (1,2) [ 0-based ] , so that final string will be "bgb" which is a palindrome.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?