Make a Palindrome
Submissions: 1010   Accuracy:

44.87%

  Difficulty: Basic   Marks: 1

Given a string of lowercase letters. Find minimum characters to be inserted in string so that it can become palindrome. We can change positions of characters in string.

Input:
First line consists of T test cases. Only line consists of a String s.

Output:
Single line output, print the count of minimum characters to be inserted.

Constraints:
1<=T<=100
1<=|String|<=10000

Example:
Input:

2
geeksforgeeks
aabbc
Output:
2
0

Explanation:
For the first test case:

geeksforgeeks can be changed as:
geeksroforskeeg
geeksorfroskeeg
and many more

For the second test case:
It can form a palindrome without insertion of any element.
abcba
bacab

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.