#K62787. Longest Palindromic Substring Length
Longest Palindromic Substring Length
Longest Palindromic Substring Length
Given a string s, your task is to determine the length of the longest palindromic substring in s. A palindromic substring is a sequence of characters that reads the same backward as forward.
The problem can be formulated mathematically as follows. Let s be a string of length n. We want to find the maximum k (with 1 ≤ k ≤ n) such that there exists an index i satisfying:
$$s[i] = s[i+k-1] \quad \text{and} \quad s[i+j] = s[i+k-1-j] \quad \text{for all } 0 \le j < k. $$It is guaranteed that the input string contains at least one character.
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line contains an integer n representing the length of the string s. The second line contains the string s itself.
outputFormat
Output to standard output (stdout) a single integer representing the length of the longest palindromic substring in s.
## sample7
racecar
7