Input
events = ['A', 'C', 'B', 'A', 'D', 'B', 'A'] required = ['A', 'B']
Output
(2, 4)
events[2:4] = ['B', 'A'] — smallest window containing both required types.
You're triaging a production incident. The logs from one node contain a sequence of event types, and you need to find the smallest contiguous window of log entries that contains every event type from a required set. Imp...
main.pyEditable starterevents = ['A', 'C', 'B', 'A', 'D', 'B', 'A'] required = ['A', 'B']
(2, 4)
events[2:4] = ['B', 'A'] — smallest window containing both required types.
events = ['X', 'X', 'X'] required = ['Y']
(0, 0)
No 'Y' anywhere in the log.
How would you change the algorithm if the events were arriving as a stream and you couldn't hold all of them in memory at once?