Longest Palindromic Substring

Statement

Given a string of characters, find and return the longest palindromicA palindrome is a sequence of characters that reads the same backwards as forwards, for example, racecar. substring within the input string.

Examples

Example 1

Sample input

"bccd"

Expected output

"cc"

Example 2

Sample input

xaabacxcabaaxcabaax

Expected output

xaabacxcabaax

Try it yourself

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.