Question
A training app tags each day with a workout-type id (integers; 1 = run, 2 = lift, and so on). For a weekly variety report, it needs the number of distinct workout types in every window of k consecutive days. Given the ids list types and k (1 <= k <= number of days), return a list with one distinct-count per window, in order. Update a count map as the window slides — do not rescan each window. Example: types = [1, 2, 1, 3, 3], k = 3 gives [2, 3, 2].
distinct_per_window(types: list[int], k: int) → list[int][[1,2,1,3,3],3]out[2,3,2]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.