Meta IT receives a chronological stream of support event categories from its internal service tooling. Given the category for each event, find the length of the longest contiguous window containing at most k distinct categories.
Use a sliding window or multi-pointer approach that runs in O(n) time.
Implement longest_support_window(events, k).
events, a list of integers where each integer identifies an event category, and k, a non-negative integer.k distinct values.k is 0, return 0.def longest_support_window(events, k):