The Longest Palindrome, Fast
Print the length of the longest palindromic substring of S. |S| can be up to a million, so O(n²) center-expansion is too slow.
Input: one line with the string S.
Output: the longest palindromic substring length.
Constraints:
- 1 ≤ |S| ≤ 106
- lowercase letters
Sample Tests
Input 1
babad
Output 1
3
Input 2
cbbd
Output 2
2
Discussion (opens after you solve — no spoilers before)
No comments yet.