Count Special Palindromic Substrings
Given a string, count the number of special palindromic substrings where a special palindrome is defined as either having all identical characters or having all characters identical except for the middle character. Return the total count of such substrings that can be formed from the input string.
Asked at:
6sense
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid February, 2026
6sense
Senior
A string is a special palindrome string if either of two conditions is met: all of the characters are the same, all of the characters except the middle are the same. A special palindromic substring is any substring of a string which meets one of those criteria. Given determine how many special palindromic substrings can be formed from it. For example, given the string m, n, o, p, o, o, we have the special palindromic substrings: m, n, o, n, o, p, o, o, n, o, o, n, o, o, p, o, o. Find the count of special palindromic substrings in the given string.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.