count special palindromic
Submissions: 914   Accuracy:

16.34%

  Difficulty: Medium   Marks: 4

Given a String s, count all special palindromic substrings of size greater than 1. A Substring is called special palindromic substring if all the characters in the substring are same or only the middle character is different for odd length.Example “aabaa” and “aaa” are special palindromic substrings and “abcba” is not a special palindromic substring.

Input: the first line of input contains integer T denoting the number of test cases. Each test case contains string S.
Output:
For each test case, print count of special palindromic substrings.
Constraints:

1<=T<=100

1<=N<=10^5
Example:

INPUT:
2
abab

aaba

OUTPUT:
2
2

explanation :
tese case 1 : All Special Palindromic substring size > 1 are : "aba", "bab"

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

Author: Nishant_Singh


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.