FastPrepLongest Palindromic Substring
Problems/Longest Palindromic Substring

Longest Palindromic Substring

EPAM logoEPAM● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names a well-known task. We chose the function signature, a fixed order for the output, and the limits. Our version is about 98% the same as the reported question.

Given a non-empty string s, return its longest contiguous palindromic substring.

A single character is a palindrome. If several longest answers exist, return the leftmost one. Your solution must use linear time.

Function

longestPalindrome(s: String) → String

Examples

Example 1

s = "babad"return = "bab"

Both bab and aba have maximum length three; bab starts first.

Example 2

s = "cbbd"return = "bb"

The longest palindromic substring is bb.

Constraints

  • 1 <= s.length <= 200000
  • s contains lowercase English letters.
  • Your algorithm must run in O(n) time.
  • If several longest palindromic substrings exist, return the leftmost one.

Source note: Author-written prompt excerpt retained for source fidelity.

More EPAM Phone Screen questions

  • Container With Most WaterPHONE SCREEN · Seen Oct 2026
  • Convert an Entry List to a MapPHONE SCREEN · Seen Oct 2026
  • Count Array Element FrequenciesPHONE SCREEN · Seen Oct 2026
  • Find First and Last Position of Element in Sorted ArrayPHONE SCREEN · Seen Oct 2026
  • Group AnagramsPHONE SCREEN · Seen Oct 2026
  • Longest Consecutive SequencePHONE SCREEN · Seen Oct 2026
  • Max Consecutive Ones IIIPHONE SCREEN · Seen Oct 2026
  • Minimum Currency ConversionsPHONE SCREEN · Seen Oct 2026
  • Next Greater Element IPHONE SCREEN · Seen Oct 2026
  • Partition and Group Values by ParityPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Classify Password StrengthHackerRank · OA · PHONE SCREEN · ONSITE INTERVIEWHackerRank interview questions
  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
  • Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Dasher Pay with Store Waits and Peak HoursDoorDash · PHONE SCREENDoorDash interview questions
  • Fuzzy Word Lookup With One Misspelled LetterMeta · PHONE SCREENMeta interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Minimum Number of Frogs CroakingCerebras · PHONE SCREEN
  • Adjacent Pair and Run RemovalWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
All EPAM interview questionsSee EPAM hiring insights
Saved
class Solution {
    public String longestPalindrome(String s) {
      // write your code here
    }
}
Checking account…