FastPrepCount Palindromic Substrings
Problems/Count Palindromic Substrings

Count Palindromic Substrings

Pure Storage logoPure Storage● MediumFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

A string S is called palindrome if it reads the same way if spelled backwards, for example: "nolemonnomelon"; "ASANtaLivedAsAdeviLatNASA". Any non-empty string has substrings that are palindromes. For example, in the string S="hellolle", there are many of such "subpalindromes":

  • 1) ellolle
  • 2) ll, ll - note that these are two distinct substrings that only happen to be equal
  • 3) lol and lloll
  • 4) And, of course, each letter can be considered a palindrome - all 8 of them.

Write a function that, given a string S (that only consists of lowercase English letters), counts how many different ways are there to pick a palindrome substring from S.

Function

countPalindromicSubstrings(s: String) → int

Examples

Example 1

s = "hellolle"return = 13

N/A

Example 2

s = "wowpurerocks"return = 14

N/A

More Pure Storage interview questions

  • One-Shot Callback Event DispatchONSITE INTERVIEW · Seen Dec 2026
  • Perfect AND Tree Leaf UpdatesONSITE INTERVIEW · Seen Dec 2026
  • Constant-Time Set OperationsPHONE SCREEN · Seen Sep 2026
  • Rasterize a Circle with Integer PixelsONSITE INTERVIEW · Seen Sep 2026
  • Racing ResultsOA · Seen Oct 2024
  • Find DoublesOA · Seen Oct 2024
  • Set Command SimulationONSITE INTERVIEW · Seen Aug 2024
  • Count Different Palindrome SubstringsOA · Seen Jul 2024
  • Find RepetitionsOA · Seen Nov 2023
  • Bakery Quality ControlOA · Seen Nov 2023

Similar questions at other companies

  • Longest Palindromic SubsequenceAXQ Capital · OA
  • Maximum Equal-Bit Pairs in a SubsequenceAmazon · OA
  • Longest Subsequence That Is a SubstringBooking.com · OA
  • Count Digit Replacements with No Equal Adjacent DigitsMicrosoft · OAMicrosoft interview questions
  • Palindrome CounterGoldman Sachs · OAGoldman Sachs interview questions
  • Longest String ChainVisa · OAVisa interview questions
  • Minimum-Cost Digit String DecodingSquadStack.ai · OA
  • Maximum Redundancy After One Segment FlipBloomberg LP · OABloomberg LP interview questions
  • Substrings Without a Target SubsequencePhonePe · OAPhonePe interview questions
  • Minimum Edit-Distance String for Each QueryTarget · OA
All Pure Storage interview questionsSee Pure Storage hiring insights
Saved
class Solution {
    public int countPalindromicSubstrings(String s) {
      // write your code here
    }

}
Checking account…