An upload widget sends files with at most limit uploads in flight. Upload i takes durations[i] ms. Uploads start in index order: the first limit start at time 0, and whenever one finishes, the next waiting upload starts at that same moment.
Write finishTimes(durations, limit) that returns the finish time of every upload, in index order. There can be 100,000 uploads and a limit of up to 100,000.
Input: durations = [300,100,200,100,400], limit = 2 Output: [300,100,300,400,700]
Upload 2 starts at 100 when upload 1 finishes; uploads 3 and 4 start at 300.
Input: durations = [5,5,5], limit = 1 Output: [5,10,15]
With one slot, uploads run one after another.
0 <= durations.length <= 10^5, 1 <= durations[i] <= 10^41 <= limit <= 10^5Run 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 #748 Upload Finish Times. 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.