Deduplicate a replayed order stream
After a reconnect, your exchange feed replays messages, so the same order event can appear multiple times. Each event is (order_id, payload). Downstream consumers must see each order_id exactly once, in original arrival order.
events = [(101, "new"), (102, "new"), (101, "new"), (103, "new"), (102, "new")]
-> [(101, "new"), (102, "new"), (103, "new")]
Return the stream with duplicates removed, keeping the first occurrence of each id and preserving order. Aim for per event.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.