An AMD ROCm profiling pipeline receives metric labels emitted by consecutive GPU events. Given the labels and a window size, return the number of distinct labels in every contiguous window of exactly k events.
Implement an efficient sliding-window solution using a hash map. When a label enters the window, update its frequency. When a label leaves, decrement its frequency and remove it when the frequency reaches zero.
Implement distinct_metrics_in_windows(events, k).
events: a list of strings representing consecutive ROCm metric labels.k: a positive integer window size.i is the number of distinct labels in events[i:i + k].k is greater than the number of events, return an empty list.def distinct_metrics_in_windows(events, k):