01 · Question
Fixed-Length Window
Given an array of sales, find the most sales in any k-day period.
Return 0 when k <= 0 or k > len(sales).
02 · Analysis
Initialize from the first complete window, then add the entering day's sales and subtract the leaving day's sales. This maintains the exact current sum in constant time per shift. The initial maximum must be a real window, so negative totals also work. Return 0 if k <= 0 or k exceeds the input length. Time O(n), auxiliary space O(1).
03 · Solution