Your question is Debounce Rapid Input Events. 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.
Virtu Financial's Triton platform receives rapid user input events, such as symbol searches or filter changes. Implement a deterministic simulation of a trailing-edge debounce operation that keeps only the most recent event in each burst.
Given timestamped events and a debounce delay, emit an event only when no later event arrives before its scheduled execution time. Each emitted result must contain the scheduled execution timestamp and the latest event value.
An event scheduled for time t + delay is emitted before processing a new event at time t + delay. Input events are sorted by nondecreasing timestamp. Do not use real timers, sleeping, browser APIs, or asynchronous code.
Implement debounce_events(events, delay).
events is a list of two-item lists [timestamp, value], where timestamp is an integer and value is a string.delay is a nonnegative integer.[execution_timestamp, value] in execution order.def debounce_events(events, delay):