Longest Palindromic Substring

Given a string S, find the longest palindromic substring in S.

Substring of string S:

S[i...j] where 0 <= i <= j < len(S)

Palindrome string:

A string which reads the same backwards. More formally, S is palindrome if reverse(S) = S.

Incase of conflict, return the substring which occurs first ( with the least starting index ).

Example :

Input : "aaaabaaa"
Output : "aaabaaa"
Start solving Longest Palindromic Substring on Interview Code Editor
Sign Up
to access hints and editorial solutions for Longest Palindromic Substring
8151 successful submissions.
Asked In:
  • Amazon
  • Microsoft
  • Groupon
Click here to start solving coding interview questions