Peak Reading
easyA weather station streams temperature readings all day and you need the day's peak. The intern's script compares every reading against every other reading to check "is this one bigger than all the rest?" — it grinds for minutes on a busy day.
Given the list readings, return the maximum value. Do it in a single pass — and without calling max(), since the point is to feel the O(n) loop yourself.
Example 1
in readings = [13, 21, 8, 21, 5]
out 21
21 is the highest reading (it appearing twice doesn't matter).
Example 2
in readings = [-7, -2, -11]
out -2
All readings can be negative — the peak is just the least cold one.
Constraints
- · 1 <= len(readings) <= 10^5
- · -10^9 <= readings[i] <= 10^9
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.