EvalFrame Technical Mock Interviews & Coding Practice

Longest Palindromic Substring

Medium · String / DP · Algorithm problem · all problems

Given a string `s`, return the longest palindromic substring in `s`. **Examples:** ```typescript longestPalindrome("babad") // "bab" (or "aba") longestPalindrome("cbbd") // "bb" ```

Solve It in the BrowserPractice Explaining It Out Loud

Optimal Approach

  • Time complexity: O(n^2)
  • Space complexity: O(1)

Expanding around center for each of the 2n - 1 centers takes O(n) each.

Follow-Up Questions Interviewers Ask About Longest Palindromic Substring

  • Can this be solved in O(n) linear time?
    Yes, Manacher's algorithm finds the longest palindromic substring in O(n) by reusing previously computed palindrome radii.

Practice the full problem with execution, tests, and AI code review in the interactive lab — then rehearse explaining your solution in a live voice mock interview.