19 September 2026 · Advanced track
Steadiest Monitor
Find the monitor with the most reported units, preferring the one with the steadiest report spacing.
A community network logs air-quality reports in the order they arrive. Each report names a monitor and its number of measured units. Add the reported units for each monitor. Return the monitor with the largest total number of units. If monitors tie for the largest total: - Return the monitor whose largest gap between consecutive reports is smallest. - Treat a monitor with one report as having a largest gap of 0. - If those gaps are also tied, return the monitor name that comes first alphabetically.
Constraints
reports contains from 1 to 1,000 recordsEach monitor name contains from 1 to 30 lowercase ASCII lettersunits is an integer from 1 to 10,000A report gap is the difference between the positions of consecutive reports from the same monitor
Function signature
def steadiest_monitor(reports):