Problem, as an interviewer would state it: "Build a toast notification queue. Multiple toasts can be triggered in quick succession, but only ONE should ever be visible at a time — each one auto-dismisses after a delay, then the next one in line appears. Enqueue three messages back to back and show me it genuinely never displays more than one at once."
Examples:
queue.enqueue("Saved!");
queue.enqueue("Upload complete");
queue.enqueue("3 new messages");
// exactly one toast visible at any given moment, in the order they were enqueued
Clarifying questions expected:
- Is the display duration the same for every toast, or configurable per message?
- Should a toast be dismissible early by the user (click to dismiss), in addition to auto-dismiss?
- Is there a maximum queue length, or can it grow unbounded?
Code / implementation expected: Yes — a real, live-verified implementation showing exactly one active toast at every sampled point in time across all three messages.