Crash window alert
A crash-reporting backend receives crash timestamps from a mobile app as integer Unix seconds, sorted ascending (duplicates allowed — many devices can crash in the same second). Fire an alert if any 60-second window contains at least k crashes: a window covers timestamps t through t + 59 inclusive, so two crashes belong to a common window exactly when they are at most 59 seconds apart. Given the timestamps and k (k >= 1), return true if some window holds k or more crashes.
Implement
has_crash_spike(timestamps: list[int], k: int) → boolExamples
in
[[10,30,55,62,200],4]outtrueWhat 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 14 min
solution.py
InputExpectedGot
[[10,30,55,62,200],4]truenot run yetsample