Skip to main content

Longest Palindromic Substring

MediumPremium

Given a string s, determine the longest palindromic substring in s. A substring is considered a palindrome if it reads the same forward and backward.

A substring is a contiguous sequence of characters within a string. The longest palindromic substring is the substring with the maximum length that satisfies this condition.

Examples

Input: "abacc" Output: "aba" Explanation: "aba" is longer than "cc"