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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Debounce From Scratch
00:00
5 left

Debounce From Scratch

MediumPython

Problem

In Informatica Intelligent Data Management Cloud, an asset search field should avoid processing every keystroke. Implement a deterministic simulation of a trailing-edge debounce operation that emits only the most recent event after no newer event arrives during the configured delay.

Formal Specification

Implement debounce(events, delay), where events is a list of [timestamp, value] pairs sorted by nondecreasing integer timestamp, and delay is a positive integer quiet period. Each value may be a string or another JSON-compatible value. Return a list of [invocation_timestamp, value] pairs.

When an event arrives, replace the pending event and reset its deadline to timestamp + delay. If the next event arrives at or after the pending deadline, emit the pending event at its deadline before processing the new event. Emit any remaining pending event after the input ends. This models trailing-edge debounce behavior.

Constraints

  • 0 <= events.length <= 10^5
  • Timestamps are integers in nondecreasing order
  • 1 <= delay <= 10^9
  • Event values are JSON-compatible
  • Events at exactly the deadline emit the previous value before the new event is processed

Function Signature

def debounce(events, delay):
Interviewer

Your question is Debounce From Scratch. 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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.