#K42637. Longest Consistent Period
Longest Consistent Period
Longest Consistent Period
You are given an array of integers. Your task is to find the length of the longest contiguous subarray in which every element is identical.
For example, given the array $$A = [5, 5, 3, 3, 3, 2, 2]$$, the longest subarray of equal elements is [3, 3, 3] with a length of 3.
Input/Output
You need to implement a solution that reads from standard input and outputs to standard output.
inputFormat
The input consists of two lines:
- The first line contains an integer $$N$$ representing the number of elements in the array.
- The second line contains $$N$$ space-separated integers.
If $$N = 0$$, then the array is empty and no second line will be provided.
outputFormat
Output a single integer: the length of the longest contiguous subarray in which all elements are equal.
## sample7
5 5 3 3 3 2 2
3