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"
Interview Code Editor
Hints
  • Hint 1
  • Solution Approach
  • Complete Solution
5934 successful submissions.
Asked In:
  • Amazon
  • Microsoft
  • Groupon
Click here to jump start your coding interview preparation