Pearson MyLab records student interaction events in chronological order. Detect students whose activity exceeds an allowed interaction count within any fixed-size sliding time window.
An interaction log is represented as a list of two-item arrays: [timestamp, student_id]. Timestamps are integer seconds and the logs are sorted by nondecreasing timestamp. For each student, return the student ID if any window of window_size seconds contains more than max_events interactions.
Treat a window ending at timestamp t as the inclusive interval [t - window_size + 1, t]. Return the anomalous student IDs in lexicographic order. A student should appear at most once.
Implement detect_anomalies(logs, window_size, max_events).
logs, a list of [int, str] pairs; window_size and max_events, positive integers.max_events in at least one window.def detect_anomalies(logs, window_size, max_events):