Code RoomLongest active streak
MediumPrep Room Coding #625

Longest active streak

CodingAlgorithms & data structuresEntry–Mid~15 min

A coach reviews a runner’s daily step counts and wants the longest streak of consecutive days that stays "active", tolerating a few off-days: a stretch qualifies if at most k of its days fall strictly below the threshold t. Given steps, t, and k (k >= 0), return the length of the longest qualifying stretch. Example: steps = [12000, 4000, 13000, 11000, 3000, 2000, 14000], t = 10000, k = 1 gives 4 (days 0 through 3).

Implement
longest_active_stretch(steps: list[int], t: int, k: int) → int
Examples
in[[12000,4000,13000,11000,3000,2000,14000],10000,1]out4
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 15 min
InputExpectedGot
[[12000,4000,13000,11000,3000,2000,14000],10000,1]4not run yetsample