← Questions
Many timers on top of one underlying timer
0
I was asked this
No reports yet. Sign in to say where you were asked it.
The system offers a single timer: setting it replaces any earlier setting, and it calls a handler when it expires. Build a class that supports many independent timers on top of it: add a timer for a timestamp, cancel one, and fire each at the right time. Keep the next deadline in a min-heap and re-arm the single timer whenever the earliest deadline changes.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
