Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Debounce Rapid Input Events
00:00
5 left

Debounce Rapid Input Events

MediumPython

Problem

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.

Formal Specification

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.
  • Return a list of two-item lists [execution_timestamp, value] in execution order.
  • If multiple events belong to one burst, emit only the final event in that burst.

Constraints

  • 0 <= events.length <= 10^5
  • 0 <= events[i][0] <= 10^9
  • 0 <= delay <= 10^9
  • Event timestamps are sorted in nondecreasing order
  • Each event value is a nonempty string

Function Signature

def debounce_events(events, delay):
Interviewer

Your question is Debounce Rapid Input Events. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.