Given a string s, find the minimum number of characters you need to insert at the beginning in order to make the string a palindrome.
s: “baaba”
Result: 1
s: “bab”
Result: 0
The first line contains an integer ‘T’ denoting the number of the test cases.
For each test case, the input has one line with the string ‘s’.
For each test case, the output has one line with an integer ‘val’ denoting the minimum number of characters to insert.
2
a
abc
0
2
1 <= T <= 100
1 <= s length <= 10000
The characters of strings are lowercase English alphabets.