Loading...
Loading...
Loading...
A weather station records the temperature at noon for n days. Some winter days are below zero. Print the highest and the lowest temperature.
Example 1
Input
6 12 -3 25 7 -8 19
Output
25 -8
The warmest day is 25 and the coldest is -8.
Example 2
Input
3 -5 -2 -9
Output
-2 -9
All days are below zero, so the highest is still negative.
Try the problem first. Open one hint at a time.
Start both the highest and the lowest at the first element, not at 0.
Walk through the rest and update each one when you find a bigger or a smaller value.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor