Dsa
Prefix Sum
Easy
Temperature Anomaly Detector
You are given a list of daily temperature readings (in degrees Celsius) for a month (30 days). Your task is to identify the total number of days that had a higher temperature than the average of the previous days.
Input:
- The first line contains an integer T (1 <= T <= 30), the number of temperature readings which is guaranteed to be 30.
- The second line contains T space-separated integers representing the temperature readings.
Output:
- Print a single integer representing the number of days that had a temperature higher than the average of the preceding days.
Example Input:
30
20 22 21 23 25 24 30 31 29 27 26 24 22 21 22 24 25 28 29 30 31 32 33 34 30 29 28 27 25 24
Example Output:
12
Key concepts
prefix_sumarrayscumulative_sum
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now