Palindrome String

0

0 votes
Problem

Given a string, find the minimum number of characters to be inserted to convert it to palindrome.
For Example:
ab: Number of insertions required is 1. bab or aba
aa: Number of insertions required is 0. aa
abcd: Number of insertions required is 3. dcbabcd


Input:

The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is S.



Output:

Print the minimum number of characters.



Constraints:

1 ≤ T ≤ 10
1 ≤ S ≤ 1000
 

Sample Input
3
abcd
aba
geeks
Sample Output
3
0
3
Time Limit: 1.5
Memory Limit: 256
Source Limit:
Editor Image

?