Problem 120589 · easy · Level 01 Prerequisites & Setup

Record-Breaking Days

loops · lists · running maximum · counting

You have a list of daily high temperatures. A day is record-breaking if its temperature is strictly higher than every earlier day. The very first day always counts (there is nothing before it). Write record_days(temps) that returns how many record-breaking days there are.

Examples

Input:  temps = [20, 25, 23, 30, 30]
Output: 3
Explanation: day 1 (20), day 2 (25) and day 4 (30) set new records.

Input:  temps = []
Output: 0

Constraints

  • 0 <= len(temps) <= 10**5
  • -100 <= temps[i] <= 100

Goals

  • Track the best value seen so far while looping
  • Count events that depend on earlier items
Starting Python…