0 day streak
Anonymous · shared experience20 Oct 2025 · 8 views

Google: Earliest live timestamp in a deduplicated message stream

Interview question #Google SDE 2 DSA / coding

Problem. Messages arrive one by one, each carrying a timestamp. A message stays valid for 10 seconds after its timestamp. If the same message shows up again while an earlier copy is still valid, the repeat is dropped. At any moment the system must be able to report the timestamp of the earliest message that is still valid.

Constraints given. Timestamps never go backwards. Because the input is an unbounded stream, memory has to stay bounded, and both the lookup and the cleanup of expired entries should be O(1) amortized.

Follow-ups.

  • Move from a brute-force scan to something that respects the streaming setting.
  • How do you keep memory bounded when you cannot store the whole stream?
  • How would it behave under very high throughput, and would you use locks or a lock-free structure?

What mattered. The candidate said the interviewer barely cared about the brute force. The real signal was handling the streaming constraints, bounding memory and reasoning about concurrency. A sliding window built from a queue plus a hash set was the shape of the answer they discussed.

0 comments

Comments 0

No comments yet. Ask the author something, or add what happened in your own round.