22 August 2026
Reservoir Records
Return each water-level reading that sets a new high record.
You are given a list of non-negative water-level readings in time order, from earliest to latest. The first reading is always a new record because there are no earlier readings to compare it with. For every reading after that, check whether it is higher than every reading before it. Add each new record reading to a result list. If a reading is the same height as the current record, do not add it again. Return the result list. If there are no readings, return an empty list. For example, [3, 1, 4, 4, 6, 2] returns [3, 4, 6]. The second 4 is not included because it does not beat the earlier 4.
Constraints
0 <= len(heights) <= 100000Each height is a non-negative whole number.
Function signature
def reservoir_records(heights):