FDEInterviews logo
Coding & DSA / 62
easyOpenAIAnthropicDatadog

Maintain a sliding-window average over a stream of metrics, like tokens/sec.

A dashboard needs the average tokens/sec over the last N seconds, updated on every sample, forever. The warm-up that screens whether you evict by time and keep a running sum instead of re-summing the window each call.

Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.

A dashboard needs the average tokens/sec over the last N seconds, updated on every sample, forever. The warm-up that screens whether you evict by time and keep a running sum instead of re-summing the window each call.

20 answers per topic instead of 10, plus saved progress and bookmarks · no cardor unlock all 523 remaining answers · ₹2,000 / $25
UP NEXT ON YOUR JOURNEY
FEDITOR'S NOTE

The fork in the road is count-window versus time-window. Many candidates build a fixed-size deque (last N samples), which is wrong when samples arrive irregularly, the metric you actually want is the last N seconds. The other tell is re-summing the whole window on every read, turning an O(1) operation into O(N) and melting under a high-frequency stream. Running sum plus time-based eviction is the answer.

DISCUSSION · 0

No comments yet — be the first to share your approach.