#K81427. Longest Palindromic Substring Length
Longest Palindromic Substring Length
Longest Palindromic Substring Length
You are given a string s
and its length n
. Your task is to find the length of the longest palindromic substring in s
. A palindrome is a string that reads the same forwards and backwards.
The input is provided via standard input (stdin) where the first line is an integer n
representing the length of the string, and the second line is the string s
. Your output should be a single integer printed to standard output (stdout) representing the length of the longest palindromic substring found in s
.
Note: A substring is a contiguous sequence of characters within a string.
Examples:
- For input
7
andracecar
, the output is7
since the entire string is a palindrome. - For input
12
andabacdfgdcaba
, the output is3
(e.g., "aba"). - For input
5
andabcde
, the output is1
because each character is by itself a palindrome.
inputFormat
The first line contains an integer n
(1 ≤ n ≤ 10^5), which is the length of the string s
.
The second line contains the string s
consisting of lowercase English letters.
outputFormat
Output a single integer representing the length of the longest palindromic substring found in the given string s
.
7
racecar
7