Best goal hit window
A habit tracker stores, for each day, a 1 if the user hit their step goal and a 0 if not. For a k-day challenge recap (1 <= k <= number of days), the app shows the best window: the maximum number of goal-hit days in any k consecutive days. Given the binary list flags and k, return that maximum. Example: flags = [0, 1, 1, 1, 0, 1], k = 3 gives 3 (days 1 through 3).
Implement
max_goal_days(flags: list[int], k: int) → intExamples
in
[[0,1,1,1,0,1],3]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 10 min
solution.py
InputExpectedGot
[[0,1,1,1,0,1],3]3not run yetsample