Deduplicate stream window
Your task
Deduplicate a stream within a time window. You are given events as [timestamp, key] in non-decreasing timestamp order. An event is a duplicate (and should be dropped) if an event with the SAME key was already EMITTED with a timestamp within the last window seconds (i.e. emitted_ts > timestamp - window). Otherwise the event is emitted and becomes the new reference for that key. Return the list of emitted keys in order.
Examples
dedup_window(events: list[list], window: int) -> listExample 1
Input
dedup_window([[0, "a"], [1, "a"], [10, "a"]], 5)Output
["a", "a"]