An API dashboard stores how many requests arrived in each minute in perMinute. The on-call engineer wants the busiest stretch of exactly k minutes in a row.
Write busiestStretch(perMinute, k) that returns the largest total number of requests over any k consecutive minutes. k is never more than the number of minutes.
Input: perMinute = [4,2,7,1,8,3], k = 3 Output: 16
Minutes 2 to 4 have 7 + 1 + 8 = 16 requests.
Input: perMinute = [5,5,5], k = 3 Output: 15
There is only one stretch of 3 minutes.
1 <= k <= perMinute.length <= 1000000 <= perMinute[i] <= 10^4Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #124 Busiest Stretch of Requests. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.