#K85367. Longest Palindromic Subarray
Longest Palindromic Subarray
Longest Palindromic Subarray
Given an array of integers, your task is to find the length of the longest contiguous subarray that forms a palindrome. A palindrome is a sequence that reads the same backward as forward.
The subarray must consist of consecutive elements from the original array without rearrangement. For example, in the array [1, 2, 3, 2, 1, 5, 6], the longest palindromic subarray is [1, 2, 3, 2, 1] with a length of 5.
Note: If the array is empty, the answer is 0.
inputFormat
The input is given on a single line as space-separated integers representing the elements of the array.
outputFormat
Output a single integer which is the length of the longest contiguous palindromic subarray.## sample
1 2 3 2 1
5