#K90382. Longest Palindromic Substring Length
Longest Palindromic Substring Length
Longest Palindromic Substring Length
Given a string s, your task is to compute the length of its longest palindromic substring. A palindrome is a string that reads the same forwards and backwards. The solution should consider all possible substrings and output the length of the longest one that is a palindrome.
For example, if s = "babad", one of the longest palindromic substrings is "bab" (or "aba") which has a length of 3.
The underlying approach typically uses the technique of expanding around each center of the string. In mathematical terms, if s is the string and i is the current index, you check for palindromes by expanding on both sides of i (and between i and i+1 for even length palindromes), and then update the maximum length found.
Note: All formulas, such as the expansion length, are expressed in standard \( \LaTeX \) syntax in documentation where applicable.
inputFormat
The input is provided via standard input (stdin) as a single line containing a string s composed of lowercase letters.
For example:
babad
outputFormat
The output should be printed to standard output (stdout) as an integer, which is the length of the longest palindromic substring in the input string.
For example:
3## sample
babad
3