Maya wants to identify the longest uninterrupted sequence of wallet activity containing no more than k distinct event types. Given a list of event type strings in chronological order, return the inclusive start and end indices of the longest contiguous window with at most k distinct types. If multiple windows have the same maximum length, return the one with the smallest start index.
Implement longest_activity_window(events, k), where events is a list of strings and k is a positive integer. Return a two-element list [start, end]. If no valid window exists, return [-1, -1]. The empty input also returns [-1, -1].
Example 1
Input: events = ["send", "cash_in", "send", "pay", "pay"], k = 2
Output: [2, 4]
Explanation: The window ["send", "pay", "pay"] has two distinct types and length three, which is maximal.
Example 2
Input: events = ["pay", "cash_in", "send"], k = 1
Output: [0, 0]
Explanation: Every event type is different, so the longest valid window contains one event. The earliest such window starts at index zero.
def longest_activity_window(events, k):