Code Room
CodingEasycod-g1432
Subject Sliding windowLevel Entry–Mid~11 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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]).

Implement
count_clean_windows(readings: list[int], k: int) → int
Examples
in[[3,0,4,5,6],2]out2
What a strong answer looks like

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.

Run or narrate your approach, then ask the coach.