← Questions

Many timers on top of one underlying timer

0
GoogleCodingLast asked Dec 2025

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.

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