Code RoomError threshold crossings
EasyPrep Room Coding #505

Error threshold crossings

CodingAlgorithms & data structuresEntry–Mid~11 min

A monitoring pipeline aggregates errors into per-minute counts, giving you a list of integers in time order. An alert fires each time the count crosses the threshold from below: the value is at least threshold now, and the previous minute's value was below it. If the very first minute is already at or above threshold, that counts as a crossing too. Staying at or above threshold does not re-fire. Return how many times the alert fires.

Implement
threshold_crossings(counts: list[int], threshold: int) → int
Examples
in[[0,2,5,7,3,6],5]out2
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 11 min
InputExpectedGot
[[0,2,5,7,3,6],5]2not run yetsample