#K78792. Longest Contiguous Subarray
Longest Contiguous Subarray
Longest Contiguous Subarray
You are given an array of integers. Your task is to find the length of the longest contiguous subarray in which all the elements are equal.
For a given array \(a_1, a_2, \dots, a_n\), you need to compute the maximum length \(L\) such that there exists an index \(i\) with \(a_i = a_{i+1} = \dots = a_{i+L-1}\).
Example:
Input: 5\n1 2 2 3 3 Output: 2
In the above example, the longest contiguous subarray of equal values is either the two 2s or the two 3s.
inputFormat
The first line of input contains an integer \(T\) representing the number of test cases. Each test case is described in two lines:
- The first line contains an integer \(n\) (the length of the array).
- The second line contains \(n\) integers separated by spaces representing the elements of the array.
outputFormat
For each test case, output a single line containing one integer: the length of the longest contiguous subarray where all elements are equal.
## sample3
5
1 2 2 3 3
6
4 4 4 4 4 4
10
1 1 2 2 2 3 3 3 3 4
2
6
4
</p>