All tasks
Hardstringstwo-pointersdp

Longest Palindromic Substring

Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0

Statement

You are given a string of lowercase Latin letters. Print the length of the longest contiguous substring that is a palindrome. A palindrome reads the same forwards and backwards.

Examples

Example 1
Input
babad
Output
3
Example 2
Input
abcd
Output
1

Constraints

  • String length is between 1 and 2000
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.