#K58727. Longest Uniform Subarray
Longest Uniform Subarray
Longest Uniform Subarray
Given an array of integers for each test case, find the longest contiguous subarray in which all the elements are identical. For each test case, output two numbers: the length of the longest uniform subarray and the value of the elements in that subarray.
If there are multiple subarrays with the same maximum length, choose the one that appears first in the array.
The problem requires reading input from stdin
and writing output to stdout
.
inputFormat
The first line contains an integer T, representing the number of test cases. For each test case, the first line contains an integer N - the number of elements in the array. The second line contains N space-separated integers.
outputFormat
For each test case, print a single line containing two integers: the length of the longest contiguous subarray of identical elements and the element value. Separate the two numbers with a space.## sample
3
7
4 4 4 4 5 5 5
8
6 6 6 6 6 1 1 1
5
3 3 2 2 2
4 4
5 6
3 2
</p>