1. [OA] Debounce Function — Implement ByteDance's Input Handling
For seamless user interaction, ByteDance applications require a debounced input handler to manage user typing events efficiently. Your task is to create a debounced function that limits the rate at which a handler can fire.
function debounce(func: Function, wait: number): Function;
Example 1: Input: debounce(console.log, 200); // Call it with 'test' debouncedFunc('test'); Output: Log occurs after 200ms after typing stops Explanation: Ensures that the log function is triggered only when the user stops typing for 200ms.Constraints:
ByteDance often manages complex UI interactions that require event processing. This simulation will help understand how events are queued and processed reliably under high load. Given a list of events, your task is to implement a function that simulates the processing of these events in the order they are queued while managing concurrent events.
function processEvents(events: string[]): void;
Example 1: Input: `[
Related ByteDance Frontend Engineer interview prep