Crash window alert

Write codeMedium14 min

Your task

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.

Examples

has_crash_spike(timestamps: list[int], k: int) -> bool
Example 1
Inputhas_crash_spike([10, 30, 55, 62, 200], 4)
OutputTrue