Longest Palindromic Substring InterviewBit Solution

Problem: Longest Palindromic Substring



Problem Description:

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 a palindrome if reverse(S) = S.

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


Example :

Input : "aaaabaaa" 
Output : "aaabaaa"


Solution