#C11517. Longest Palindromic Substring via Deletion

    ID: 40842 Type: Default 1000ms 256MiB

Longest Palindromic Substring via Deletion

Longest Palindromic Substring via Deletion

Given a string ( s ) consisting of lowercase English letters, you are allowed to delete at most one character. Your task is to determine the length of the longest palindromic string that can be obtained by performing at most one deletion.

A palindrome is a string that reads the same backward as forward. For example, if ( s = \texttt{abca} ), by deleting the character 'c' we obtain ( \texttt{aba} ), which is a palindrome of length 3.

inputFormat

Input is given from standard input (stdin) as a single line containing the string ( s ).

outputFormat

Output to standard output (stdout) a single integer representing the length of the longest palindrome that can be obtained by deleting at most one character from the input string.## sample

abca
3