A search box debounces its input handler: each keystroke cancels the pending request and schedules a new one wait milliseconds later. A request is only sent when wait ms pass with no new keystroke.
Write debounceRuns(calls, wait) where calls holds the keystroke times in milliseconds, sorted ascending. Return the times when requests are sent, in order. If a keystroke happens at exactly the time a request is due, the request is sent first and the keystroke then schedules a new one.
Input: calls = [0,100,250,600], wait = 200 Output: [450,800]
0, 100, 250 are each less than 200 ms apart, so one request fires at 250 + 200. The keystroke at 600 fires at 800.
Input: calls = [0,200], wait = 200 Output: [200,400]
The request due at 200 is sent before the keystroke at 200 schedules the next one.
0 <= calls.length <= 10^50 <= calls[i] <= 10^9, sorted ascending (equal times allowed).1 <= wait <= 10^6Run 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 #719 When Does the Search Request Fire?. 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.