A search bar at Acme Shop filters a local list of item names as the user types. To avoid recomputing on every keystroke, the search should be debounced: only process a query if no newer query arrives within debounce_ms milliseconds.
Write a function that takes a list of item names, a list of timestamped query updates, and a debounce interval. Return the filtered results for each query that actually executes after debouncing.
items: a list of stringsevents: a list of [timestamp, query] pairs sorted by non-decreasing timestampdebounce_ms: a non-negative integer[run_timestamp, filtered_items] pairs, in execution ordertimestamp + debounce_ms only if no later event occurs at or before that execution time.def debounced_search(items, events, debounce_ms):