Clean sample windows

Write codeEasy11 min

Your task

A telemetry pipeline marks a dropped sample as 0; every genuine reading is nonzero. Quality reports need to know how many windows of k consecutive samples are completely clean, containing no dropped samples at all. Given readings and k (1 <= k <= number of samples), return that count. Track how many zeros are inside the current window instead of rescanning each window. Example: readings = [3, 0, 4, 5, 6], k = 2 gives 2 ([4,5] and [5,6]).

Examples

count_clean_windows(readings: list[int], k: int) -> int
Example 1
Inputcount_clean_windows([3, 0, 4, 5, 6], 2)
Output2