Problem 291597 · easy · Level 02 Linear Data Structures

Record-Breaking Days

arrays · iteration · best-so-far

sales holds a shop's daily takings. A day is record-breaking if its takings are strictly greater than every earlier day's takings. The first day is always a record. Return how many record-breaking days there were.

Examples

Input:  sales = [3, 1, 4, 4, 5]
Output: 3
Explanation: Days with 3, 4 and 5 set new records; the second 4 only ties.

Input:  sales = [9, 8, 7]
Output: 1

Constraints

  • 0 <= len(sales) <= 10**5
  • Target: O(n) time, O(1) extra space.

Goals

  • Count events while tracking a running maximum
  • Treat the first element as an automatic record
Starting Python…