FastPrepDebounced Call Times
Problems/Debounced Call Times

Debounced Call Times

Adobe logoAdobe● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: A frontend engineer's report lists writing a debounce helper among the coding tasks of a JavaScript-fundamentals first round. That is all it says: no signature, no timing rules and no tests.

We made it a timing exercise that every language can run. Our choices: calls arrive as sorted times with values; each call delays the run until wait units after it and the run uses the latest value; a call that arrives exactly when a run is due does not cancel it; there are at most 1000 calls, times up to 10^6 and wait from 1 to 10^6; the examples are new. The editorial also shows the usual JavaScript wrapper built on a timer.

The judged task matches the report at about 55%.

A debounced function waits for its callers to go quiet before it does any work. Each call says: run me wait time units from now, with my value. If another call comes before that moment, the waiting run is cancelled and the new call starts its own wait.

Call i happens at time times[i] with value values[i]. The rules:

  • Each call cancels the run that is waiting (if any) and schedules a run at times[i] + wait with values[i].
  • A waiting run that is due at time T happens before any call that arrives at time T or later, so such a call cannot cancel it.
  • Calls at the same time are handled in the order they are given.

Return every run that actually happens as a pair [run time, value], in time order.

Function

debouncedRuns(times: int[], values: int[], wait: int) → int[][]

Examples

Example 1

times = [1,3,4,10,11,20]values = [5,6,7,8,9,10]wait = 3return = [[7,7],[14,9],[23,10]]

Calls at 1, 3 and 4 come less than 3 apart, so each one pushes the run back; the run happens at 4 + 3 = 7 with the last value, 7. The calls at 10 and 11 form the next burst (run at 14 with 9), and the lone call at 20 runs at 23 with 10.

Example 2

times = [0,5]values = [1,2]wait = 5return = [[5,1],[10,2]]

The first call's run is due at 5. The second call arrives exactly at 5, so the run has already happened: both calls run, at 5 and at 10.

Example 3

times = [2,2,2]values = [3,1,4]wait = 1return = [[3,4]]

Three calls at the same moment form one burst. Only the last one counts: one run at 3 with value 4.

Constraints

  • 1 <= times.length <= 1000 and values.length == times.length
  • 0 <= times[i] <= 10^6, and times is sorted in non-decreasing order
  • 0 <= values[i] <= 10^4
  • 1 <= wait <= 10^6

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public int[][] debouncedRuns(int[] times, int[] values, int wait) {
    // Write your code here.
}
Checking account…