Longest active streak
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) → intExamples
in
[[12000,4000,13000,11000,3000,2000,14000],10000,1]out4What 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
solution.py
InputExpectedGot
[[12000,4000,13000,11000,3000,2000,14000],10000,1]4not run yetsample