Longest palindromic substring
Time limit0.5sMemory limit512 MB
Find the length of the longest contiguous substring of S that reads the same forwards and backwards.
- Level
Medium7 of 10
- Topics
- String, Binary search, Hash map
- Solved
- No attempts yet
Problem
A palindrome is a string that reads the same forwards and backwards. For example, a, aa, and aba are palindromes, while ab is not.
Given a string , write a program that finds the length of the longest palindromic substring of . A substring here is a contiguous block of characters cut out of .
Input
The first line contains the string . consists of lowercase letters only, and its length is at least 1 and at most 100,000.
Output
Print the length of the longest palindromic substring on the first line.