Longest Palindrome Span Problem

Longest Palindrome Span Problem — ExecCode Hard DSA Practice

Solve the Longest Palindrome Span problem on ExecCode. Free online hard DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Find the length of the longest palindromic substring. Manacher's algorithm answers it in linear time by expanding around mirrored centers. An eertree also stores the longest suffix palindrome at each prefix. Return that length. A single character is a palindrome of length 1. You are given: s — text Return maximum palindrome length. The substring must be contiguous.

Examples

Input {'s': 'babad'}; Output 3. Input {'s': 'cbbd'}; Output 2. Input {'s': 'a'}; Output 1

Constraints

Empty 0 Even and odd palindromes both count

Practice Longest Palindrome Span free on ExecCode. Browse DSA problems, topic map, and placement guides.