FastPrepCount Palindromic Substrings
Problems/Count Palindromic Substrings

Count Palindromic Substrings

The Voleon Group logoThe Voleon Group● MediumFULLTIMEPHONE SCREEN

Updated Aug 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The original report identifies counting palindromic substrings by expanding around centers but omits input bounds and occurrence rules. This practice version counts every contiguous occurrence, including each one-character substring, in a bounded lowercase string.

Given a non-empty string s, return the number of its palindromic substrings.

A palindrome reads the same from left to right and from right to left. Count substrings by occurrence, so equal text at different positions counts separately. Every one-character substring is a palindrome.

Function

countPalindromicSubstrings(s: String) → int

Examples

Example 1

s = "abc"return = 3

The three one-character substrings are palindromes.

Example 2

s = "aaa"return = 6

The palindromic occurrences are three copies of a, two copies of aa, and one copy of aaa.

Example 3

s = "abba"return = 6

The four individual characters, bb, and abba are palindromes.

Constraints

  • 1 <= s.length <= 2000
  • s contains only lowercase English letters.

More The Voleon Group Phone Screen questions

  • Best-Fit Plane Normal from 3D PointsPHONE SCREEN · Seen Sep 2026
  • Words with Repeated AnagramsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Longest Palindromic SubstringSiemens · PHONE SCREEN
  • Query Words Within K PositionsPalantir · PHONE SCREENPalantir interview questions
  • Edit DistanceDP World · PHONE SCREEN
  • Longest Palindromic SubstringIBM · PHONE SCREENIBM interview questions
  • Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Decode WaysThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Edit DistanceAstrotalk · PHONE SCREEN
  • Longest Palindromic SubstringeBay · PHONE SCREENeBay interview questions
  • Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Generate One-Two Strings with Sum NGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
See The Voleon Group hiring insights
Saved
class Solution {
    public int countPalindromicSubstrings(String s) {
        // Write your code here.
    }
}
Checking account…