A home page has a row of ad slots. Slot i becomes available on day readyDay[i] and stays available after that. A campaign needs blocks banners, and each banner covers size slots that are next to each other. Two banners can't share a slot.
Write earliestDay(readyDay, blocks, size) that returns the earliest day on which the campaign can be placed, or -1 if the row is too short for it.
Input: readyDay = [1,10,3,10,2], blocks = 3, size = 1 Output: 3
On day 3, slots 0, 2, and 4 are free: three banners of size 1.
Input: readyDay = [1,10,3,10,2], blocks = 3, size = 2 Output: -1
Three banners of size 2 need 6 slots, but there are only 5.
1 <= readyDay.length <= 1000001 <= readyDay[i] <= 10^91 <= blocks, size <= 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 #169 Earliest Day for Banner Slots. 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.