Code RoomActive heart rate blocks
EasyPrep Room Coding #622

Active heart rate blocks

CodingAlgorithms & data structuresEntry–Mid~12 min

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) → int
Examples
in[[100,120,140,90,110],2,110]out3
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.

0:00 of about 12 min
InputExpectedGot
[[100,120,140,90,110],2,110]3not run yetsample