Problem
Implement a function that simulates the core logic behind a debounced search bar. You are given a list of input events, where each event is a pair (timestamp_ms, query) sorted by time, and a debounce_ms delay. Return the list of API calls that should actually be made if a new keystroke cancels any pending request that has not fired yet. Each API call should be represented as (fire_time_ms, query).
Constraints
- 0 <= len(events) <= 10^5
- 0 <= timestamp_ms <= 10^9
- events is sorted by timestamp_ms in non-decreasing order
- 0 <= len(query) <= 100
- 1 <= debounce_ms <= 10^6
Function Signature
def debounced_search_calls(events, debounce_ms):
You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.


