Active heart rate blocks
A heart-rate monitor samples once per minute. A stretch of k consecutive minutes counts as an "active block" if its average rate is at least threshold. Given rates, the block length k (1 <= k <= number of samples), and threshold, return how many of the n - k + 1 blocks are active. Compare sums to k * threshold so everything stays in integers. Example: rates = [100, 120, 140, 90, 110], k = 2, threshold = 110 gives 3.
Implement
count_active_blocks(rates: list[int], k: int, threshold: int) → intExamples
in
[[100,120,140,90,110],2,110]out3What 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.
0:00 of about 12 min
solution.py
InputExpectedGot
[[100,120,140,90,110],2,110]3not run yetsample