#C8950. Longest Palindromic Substring Length
Longest Palindromic Substring Length
Longest Palindromic Substring Length
Given a string, find the length of its longest palindromic substring. A palindromic substring is defined as a contiguous sequence of characters which reads the same backward as forward. For each test case, print the length of the longest palindromic substring.
The problem can be mathematically understood as follows: For a string \( s \) of length \( n \), find the maximum \( L \) such that there exists an index \( i \) with \( 1 \leq i \leq n-L+1 \) for which the substring \( s[i..i+L-1] \) satisfies \( s[i..i+L-1] = \text{reverse}(s[i..i+L-1]) \).
inputFormat
The first line contains an integer \( T \) representing the number of test cases. Each of the following \( T \) lines contains a single string for which you need to determine the length of its longest palindromic substring.
outputFormat
For each test case, output the length of the longest palindromic substring on a separate line.
## sample3
babad
cbbd
aabcdefedcbaaa
3
2
13
</p>