Longest Palindromic Substring - aloalgo

Longest Palindromic Substring

Easy

You are given a string s.

Your task is to find the longest palindromic substring in s.

Note that:

  • A palindromic substring is a contiguous sequence of characters within s that reads the same forwards and backwards.

Return the longest palindromic substring found in s.

Example 1

Input
"banana"
Output
"anana"
Explanation:

In 'banana', 'anana' is the longest substring that reads the same forwards and backwards.

Example 2

Input
"afternoon"
Output
"noon"
Explanation:

In 'afternoon', 'noon' is the longest palindromic substring and has an even number of letters.

Example 3

Input
"a"
Output
"a"
Explanation:

The single character "a" is a palindrome.

Loading...
Input
"banana"
Output
"anana"

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!