sales with a shop's revenue per day and an integer width. Choose three non-overlapping runs of consecutive days, each exactly width days long, so that their combined revenue is as large as possible.
Return the starting indices of the three runs in increasing order (0-based). If several choices tie, return the lexicographically smallest list of starts.sales=[3, 1, 4, 1, 5, 9, 2, 6], width=2 → [1, 4, 6]
Window sums by start are 4, 5, 5, 6, 14, 11, 8. The best is [1, 4] + [5, 9] + [2, 6] = 5 + 14 + 8 = 27, starting at 1, 4 and 6. Starting the first window at 2 gives the same total, but [1, 4, 6] is the smaller list.
sales=[2, 2, 2, 2, 2, 2, 2], width=2 → [0, 2, 4]
Every triple of windows totals 12, so the leftmost one wins: [0, 2, 4].
sales=[7, 1, 8], width=1 → [0, 1, 2]
width ≤ ⌊len(sales) / 3⌋sales=[3, 1, 4, 1, 5, 9, 2, 6], width=2
[1, 4, 6]
Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.