


If all the characters in the substring are the same.
If the length of the substring is odd and only the middle element is different, while all the other characters are the same.
“aba” is a special palindrome, while “abaa” is not
The first line contains an integer ‘T’, which denotes the number of test cases or queries to be run. Then the test cases are as follows.
The first and the only line of each test case contains the string 'STR'.
For each test case, print the count of special palindromic substrings.
Print the output of each test case in a separate line.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= |STR| <= 10000
Time limit: 1 sec
The basic approach is to create all possible substrings from the given string and then count the number of special palindromic substrings from them.
In this approach we will be creating two cases: