Your question is Debounce From Scratch. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In Informatica Intelligent Data Management Cloud, an asset search field should avoid processing every keystroke. Implement a deterministic simulation of a trailing-edge debounce operation that emits only the most recent event after no newer event arrives during the configured delay.
Implement debounce(events, delay), where events is a list of [timestamp, value] pairs sorted by nondecreasing integer timestamp, and delay is a positive integer quiet period. Each value may be a string or another JSON-compatible value. Return a list of [invocation_timestamp, value] pairs.
When an event arrives, replace the pending event and reset its deadline to timestamp + delay. If the next event arrives at or after the pending deadline, emit the pending event at its deadline before processing the new event. Emit any remaining pending event after the input ends. This models trailing-edge debounce behavior.
def debounce(events, delay):