FastPrepCount Palindromic Substrings
Problems/Count Palindromic Substrings

Count Palindromic Substrings

Airbnb logoAirbnb● MediumINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report identifies a string task that counts palindromic substrings but omits the additional conditions used in that assessment. This practice version uses the conventional positional count and matches the visible seed at about 65%.

Given a string text, return the number of palindromic substrings in it.

A palindrome reads the same forward and backward. Substrings are counted by their positions, so equal text appearing at different positions contributes more than once. Every one-character substring is a palindrome.

Function

countPalindromicSubstrings(text: String) → int

Examples

Example 1

text = "abc"return = 3

The palindromic substrings are "a", "b", and "c".

Example 2

text = "aaa"return = 6

There are three one-character palindromes, two occurrences of "aa", and one "aaa".

Constraints

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

More Airbnb Online Assessment questions

  • Bouncing DiagonalsOA · Seen Dec 2026
  • Count Numbers Not Equal to the First TwoOA · Seen Dec 2026
  • Garden Sprinkler PlacementOA · Seen Dec 2026
  • Theme Park Shuttle Wait TimeOA · Seen Dec 2026
  • Count Card Duel RoundsOA · Seen Nov 2026
  • Count Lamps Lighting Each PointOA · Seen Nov 2026
  • Simulate Orchard Rot SpreadOA · Seen Nov 2026
  • Sort Adjacent PairsOA · Seen Nov 2026
  • In-Memory File SystemOA · Seen Nov 2026
  • Task Management SystemOA · Seen Nov 2026

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

Interview reports that mention this question

  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)

Airbnb interview experiences

  • Airbnb OA · November 2026
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public int countPalindromicSubstrings(String text) {
      // Write your code here.
    }
}
Checking account…