Deduplicate stream window
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.
Implement
dedup_window(events: list[list], window: int) → listExamples
in
[[[0,"a"],[1,"a"],[10,"a"]],5]out["a","a"]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
[[[0,"a"],[1,"a"],[10,"a"]],5]["a","a"]not run yetsample