#K91792. Longest Contiguous Subarray
Longest Contiguous Subarray
Longest Contiguous Subarray
Given an array, your task is to find the length of the longest contiguous subarray where all the elements are equal.
This problem tests basic iteration and counting techniques. You are required to process multiple test cases. For each test case, find the maximum number of consecutive identical elements in the array.
In mathematical terms, for an array \(a = [a_1, a_2, \dots, a_n]\), determine the maximum \(k\) such that there exists an index \(i\) with \(a_i = a_{i+1} = \cdots = a_{i+k-1}\). Formally, the answer is given by:
$$\max_{1 \le i \le n} \{ k \;\text{ such that } a_i=a_{i+1}=\cdots =a_{i+k-1} \}$$
inputFormat
The input begins with a single integer \(T\) denoting the number of test cases. Each test case consists of the following:
- An integer \(N\) representing the length of the array.
- A line with \(N\) space-separated integers denoting the elements of the array.
outputFormat
For each test case, output a single integer on a new line indicating the length of the longest contiguous subarray with all equal elements.
## sample2
7
1 2 2 2 3 3 4
5
5 5 5 5 5
3
5
</p>