Temperature Swing
Easy · rating 900 · Arrays
A weather station logged n temperature readings. The first line contains n. The second line contains n integers. Print the difference between the highest and lowest reading.
Editorial
Temperature Swing reports the spread between the hottest and coldest reading — the maximum minus the minimum. A single pass can track both extremes at once.
print(max(temps) - min(temps))Complexity
Time: O(n). Space: O(1).
Related problems
- Add Two Arrays — Easy
- Alternating Sum — Easy
- Array Range — Easy
- Class Average — Easy
- Count Even Numbers — Easy
- Floor of Average — Easy