#114. 最大镜像段长度
最大镜像段长度
Largest Mirror Section
Background
Congcong enjoys playing with arrays. One day, he discovered an interesting array pattern, which he called a "mirror section."
Problem Description
We'll say that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group appears in reverse order. For example, the largest mirror section in is length 3 (the part). Return the size of the largest mirror section found in the given array.
Input Format
Input is given from standard input in the following format.
A single line containing several integers, separated by spaces.
Output Format
Output is printed to standard output in the following format.
The size of the largest mirror section.
Sample
1 2 3 8 9 3 2 1
3
1 2 1 4
3
7 1 2 9 7 2 1
2
Sample Explanation
For the first sample, the array is . The section at the beginning has its reverse appearing later in the array. The length of this mirror section is 3. This is the largest such section.
For the second sample, the array is . The section at the beginning has its reverse appearing later in the array (it is itself reversed). The length is 3.
For the third sample, the array is . The section at index 1 has its reverse appearing at index 5. The length is 2. The section at index 0 has its reverse appearing at index 4. The largest length is 2.
Constraints
Time limit: 1 second, Memory limit: 1024 KiB for each test case.