FastPrepLongest Palindromic Substring
Problems/Longest Palindromic Substring

Longest Palindromic Substring

InMobi logoInMobi● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an InMobi phone screen. The report gives the goal for the substring and the rule that ties go to the earliest start. It does not give the alphabet or limits on the numbers. Our version is about 97% the same as the reported question.

Given a string text, return its longest contiguous substring that is a palindrome.

If multiple palindromic substrings have the maximum length, return the one with the smallest starting index.

Function

longestPalindromicSubstring(text: String) → String

Examples

Example 1

text = "ababc"return = "aba"

Both aba and bab have length 3. The substring aba starts earlier.

Example 2

text = "cbbd"return = "bb"

The longest palindromic substring is bb.

Constraints

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

More InMobi Phone Screen questions

  • House Robber IPHONE SCREEN · Seen Aug 2026
  • Word Break IIPHONE SCREEN · Seen Aug 2026
  • Bus Station Seat AllotmentPHONE SCREEN · Seen Mar 2026
  • Find Missing and Duplicate IntegerPHONE SCREEN · Seen Mar 2026
  • Frequency Equals Card ValuePHONE SCREEN · Seen Mar 2026
  • Frog Position After T SecondsPHONE SCREEN · Seen Mar 2026
  • IPOPHONE SCREEN · Seen Mar 2026
  • Evaluate DivisionPHONE SCREEN · Seen Dec 2025
  • Compare Version NumbersPHONE SCREEN · Seen Feb 2022
  • Count Array DerangementsPHONE SCREEN · Seen Feb 2022

Similar questions at other companies

  • Longest Palindromic SubstringSiemens · PHONE SCREEN
  • Longest Palindromic SubstringIBM · PHONE SCREENIBM interview questions
  • Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Longest Properly Closed Bracket RunAdobe · PHONE SCREENAdobe interview questions
  • Indexed Proximity SearchStripe · PHONE SCREENStripe interview questions
  • Longest Palindromic Substring LengthMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Longest Subsequence That Is a SubstringExpedia · OAExpedia interview questions
  • Longest Palindromic SubstringGoogle · ONSITE INTERVIEWGoogle interview questions
  • Longest Subsequence which is a SubstringSalesforce · OASalesforce interview questions
  • Query Words Within K PositionsPalantir · PHONE SCREENPalantir interview questions
All InMobi interview questionsSee InMobi hiring insights
Saved
class Solution {
    public String longestPalindromicSubstring(String text) {
        // write your code here
    }
}
Checking account…