#K67002. Longest Palindromic Substring Length
Longest Palindromic Substring Length
Longest Palindromic Substring Length
You are given one or more test cases, each consisting of a list of strings. For each string, your task is to determine the length of the longest substring that is a palindrome.
A palindrome is a string that reads the same forward and backward. Mathematically, for a string s of length n, a substring s[i...j] (with 1 ≤ i ≤ j ≤ n) is a palindrome if:
Your goal is to output, for each string in a test case, the value $$L = \max_{1 \leq i \leq j \leq n}\{ (j-i+1) \;|\; s[i \ldots j] \text{ is a palindrome} \}.$$
Note that each test consists of several strings, and you must process all of them.
## inputFormatThe input is read from standard input (stdin) and has the following format:
- The first line contains an integer
T
, the number of test cases. - For each test case:
- The first line contains an integer
N
, the number of strings in this test case. - The next
N
lines each contain a non-empty string.
- The first line contains an integer
All strings consist only of lowercase English letters.
## outputFormatFor each test case, output one line containing N
integers separated by a single space. Each integer is the length of the longest palindromic substring of the corresponding string.
The output is written to standard output (stdout).
## sample2
1
abba
1
abcde
4
1
$$