#K81427. Longest Palindromic Substring Length

    ID: 35751 Type: Default 1000ms 256MiB

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 and racecar, the output is 7 since the entire string is a palindrome.
  • For input 12 and abacdfgdcaba, the output is 3 (e.g., "aba").
  • For input 5 and abcde, the output is 1 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.

## sample
7
racecar
7