A monument's frieze is inscribed with a single continuous band of lowercase English letters, given as a string s. A mirror span is any contiguous substring of s (a run of consecutive letters) that reads identically left to right and right to left.
Find the length of the longest mirror span in the frieze.
A single line containing the string s (lowercase English letters only).
A single integer: the length of the longest palindromic substring of s.
s <= 2000s contains only lowercase English letters (a-z).Example 1
Input
banana
Expected
5
Explanation
The longest contiguous mirror span is 'anana', of length 5.
Example 2
Input
abcde
Expected
1
Explanation
No two adjacent letters match, so the longest mirror span is a single letter, length 1.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →