Problems > Longest Palindromic Substring

Longest Palindromic Substring

Difficulty: 1500 2000 ms 128 MB

strings

Print the length of the longest contiguous palindrome inside S.

Input: one line with the string S.

Output: the length of the longest palindromic substring.

Constraints:

  • 1 ≤ |S| ≤ 1000
  • lowercase letters

Sample Tests

Input 1
babad
Output 1
3
Input 2
abacdfgdcaba
Output 2
3

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.