You are given an array A of N integers. Your task is to find two pieces of information: the largest value in the array, and the number of times that largest value appears.
You must implement a function that processes the array and determines these two values.
The first line contains a single integer N, the number of elements in the array.
The second line contains N space-separated integers, representing the elements of the array A.
Your function should return the maximum element and its frequency. The runner code will handle printing these two values on a single line, separated by a space.
This problem can be solved efficiently in a single pass (O(N) time complexity) through the array. You should keep track of the current maximum element seen so far and its count. If you find a new, larger maximum, you reset the count.
5
2 5 1 5 4
5 2
The largest element in the array is 5. It appears 2 times.
The expected time complexity is O(N).
1 <= N <= 10^5
-10^9 <= A[i] <= 10^9
Time Limit: 1 sec