#K67852. Longest Palindromic Substring Length
Longest Palindromic Substring Length
Longest Palindromic Substring Length
Given a string s
, your task is to find the length of the longest substring of s
that is a palindrome. A palindrome is a string that reads the same backward as forward. Use the optimal algorithm to achieve this.
Note: The problem requires you to work with standard input and output. You should read the input from stdin
and write the result to stdout
. In your solution, if needed, you can use the following mathematical representation for the expansion process:
\( L = \text{right} - \text{left} - 1 \)
inputFormat
The input consists of a single line containing one string s
(with no spaces) for which you have to determine the length of the longest palindromic substring.
For example:
babad
outputFormat
Output a single integer representing the length of the longest palindromic substring found in s
.
For example, for the input above, the correct output is:
3## sample
babad
3