InterviewDB Question

Trailer: Implement a Fixed-Size Trailing Buffer That Captures the Last N Events

Question Details

Round 1 - Coding / OOD Problem Design a Trailer data structure — a fixed-capacity circular buffer that keeps only the last N items added. Support adding items, iterating in insertion order, and querying the current count. Example Follow-ups What is the time complexity of add and iteration in your implementation? How would you make this thread-safe for concurrent producers and consumers? How would you extend this to support a window_sum() or window_average() that operates on numeric items in O(1)…

Full Details

🔒

Unlock all Samsara questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a samsara interview during the phone round.

It covers the following topics: Coding, Queue, Ood, Phone .