Code Room
CodingMediumcod-g1318
Subject Log processingLevel Entry–Mid~14 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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) → bool
Examples
in[[10,30,55,62,200],4]outtrue
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.