#K75832. Longest Contiguous Palindromic Subarray
Longest Contiguous Palindromic Subarray
Longest Contiguous Palindromic Subarray
You are given an array of integers of length \(N\). A contiguous subarray is considered palindromic if it reads the same forwards and backwards.
Your task is to determine the length of the longest contiguous subarray which is a palindrome.
Definition:
A subarray \(A[l \ldots r]\) is palindromic if \(A[l] = A[r], A[l+1] = A[r-1], \dots \). Formally, for \(0 \leq l \leq r < N\), the subarray is palindromic if
[ \forall, 0 \leq i \leq r - l, \quad A[l+i] = A[r-i] ]
Example:
Consider the array: [1, 2, 3, 4, 3, 2, 1]. The entire array is a palindrome so the answer is 7.
inputFormat
The first line of the input contains a single integer \(N\), the number of elements in the array. The second line contains \(N\) space-separated integers representing the array.
outputFormat
Output a single integer, which is the length of the longest contiguous palindromic subarray.
## sample7
1 2 3 4 3 2 1
7