#K67752. Longest Same Subarray
Longest Same Subarray
Longest Same Subarray
Given an array of integers, find the length of the longest contiguous subarray in which all elements are the same.
Problem Statement: You are provided with an integer n representing the size of the array, followed by n space-separated integers. Your task is to compute the maximum number of consecutive occurrences of the same number in the array.
The solution should read from stdin
and write the result to stdout
.
The answer must be computed using a single pass through the array with an O(n) time complexity.
inputFormat
The first line contains an integer n, the number of elements in the array. The second line contains n space-separated integers.
outputFormat
Output a single integer representing the length of the longest contiguous subarray where all the elements are the same.
## sample10
1 1 2 2 2 3 3 3 3 1
4