Baseline Arrays · Easy O(n) · O(1)
A solar farm streams one ampere reading per panel into a rolling buffer each minute. The hardware team needs the single highest reading the string ever produced so they can size the inline fuse. Return that peak value.
Input: An integer n followed by an array A of n integer readings.
Output: A single integer: the maximum element of A.
1 <= n <= 10^5-10^9 <= A[i] <= 10^9Input: {"n":5,"A":[1,8,7,56,90]}
Output: 90
Scanning the five readings, 90 is the highest value encountered.
Input: {"n":6,"A":[4,15,8,23,16,42]}
Output: 42
The peak sits at the end of the buffer, so the scan cannot stop early.