Find the Longest Palindromic Substring

Last updated: August 26, 2026

Quick Overview

The question asks the candidate to find the longest palindromic substring within a given string, which is a common problem in coding interviews.

eBay
Coding & Algorithms
Software Engineer
eBay
August 26, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

3

0

30 solved


The question asks the candidate to find the longest palindromic substring within a given string, which is a common problem in coding interviews.

This question is typically asked during the technical screening round at eBay to assess a candidate's problem-solving skills and understanding of algorithms. The interviewer is evaluating the candidate's ability to implement an efficient solution, as well as their understanding of time complexity and optimization techniques. Candidates are expected to articulate their thought process clearly while solving the problem.

What the Interviewer Expects
  • Clearly explain the approach to finding the longest palindromic substring.
  • Implement an efficient solution, preferably O(n^2) or better.
  • Discuss the time and space complexity of the proposed solution.
  • Handle edge cases, such as empty strings or strings with no palindromes.
  • Optimize the solution if possible and explain the reasoning behind the optimizations.
Key Topics to Cover
Dynamic Programming
String Manipulation
Time Complexity
Algorithm Optimization
Edge Cases
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Can you explain how your algorithm handles edge cases?
  • What is the time complexity of your solution?
  • How would you optimize your solution further?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Approach

To find the longest palindromic substring, I will use the expand around center technique. This approach involves treating each character (and each pair of characters for even-length palindromes) a...

Algorithm

The algorithm can be implemented as follows:

  1. Initialize a variable to keep track of the start and end indices of the longest palindrome found.
  2. Iterate through each character in the string, trea...

Submit Your Answer
Markdown supported

Related Questions