Cloud Security Services groups consecutive security alerts into investigation windows. Given an array of alert type identifiers and an integer k, return the maximum length of a contiguous sequence containing at most k distinct alert types.
Use a sliding-window technique that expands the right boundary and moves the left boundary whenever the window becomes invalid.
Implement longest_alert_window(alerts, k).
alerts, a list of integers representing alert types, and k, a non-negative integer.k distinct values.0 when alerts is empty or k is 0.def longest_alert_window(alerts, k):