FastPrepDebounced Autosave with Cancel and Flush
Problems/Debounced Autosave with Cancel and Flush

Debounced Autosave with Cancel and Flush

Rippling logoRippling● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Every rule here is our choice. An edit books a save wait units later and replaces any save still waiting, so the newest value wins. Cancel drops the waiting save. Flush makes it happen at the flush time, and does nothing when no save waits. A save that is due at time T happens before any operation at T or later. Operations at the same time go in the given order, and the last waiting save happens at its due time. The cancel and flush controls, the autosave story, the names, the limits and the examples are ours too.

The report places this task in a first-round frontend interview. About this task, it says only that the candidate wrote a debounce helper in JavaScript the common textbook way. It gives no signature, timing rules or tests.

This version checks when saves happen. It cannot check the JavaScript side, a wrapper that keeps one timer in a closure. The editorial covers that.

Our version is about 50% the same as the reported question.

A form saves itself a little while after you stop typing. Each edit asks for a save wait time units later, and it replaces the save that is still waiting, if there is one. This is called debouncing: a quick run of edits leads to one save, with the newest value. Two more controls act on the waiting save: cancel drops it, and flush makes it happen right away.

Operation i happens at time times[i]. At most one save waits at any moment.

  • "edit": drop the waiting save, if any, and book a new save of values[i] at time times[i] + wait.
  • "cancel": drop the waiting save, if any. Nothing is saved.
  • "flush": if a save is waiting, it happens now, at time times[i], with its value. If nothing is waiting, nothing happens.

A waiting save that is due at time T happens before any operation at time T or later, so such an operation cannot replace, drop or flush it. Operations at the same time are handled in the order they are given. After the last operation, a save that is still waiting happens at its due time. For "cancel" and "flush", values[i] is 0 and is not used.

Return every save that happens as a pair [time, value], in the order they happen. Return an empty list if no save happens.

Function

autosaveRuns(operations: String[], times: int[], values: int[], wait: int) → int[][]

Examples

Example 1

operations = ["edit","edit","edit","flush","edit","edit","cancel","edit"]times = [0,2,3,4,10,11,13,20]values = [5,6,7,0,8,9,0,4]wait = 5return = [[4,7],[25,4]]

The edit at 0 books a save for 5. The edits at 2 and 3 each replace it, so the save is now due at 3 + 5 = 8 with value 7. The flush at 4 runs that save right away: [4,7]. The edits at 10 and 11 book a save for 16 with value 9, but the cancel at 13 drops it. The edit at 20 books a save for 25. Nothing comes after it, so it runs: [25,4].

Example 2

operations = ["edit","flush","edit","cancel"]times = [1,4,6,9]values = [3,0,8,0]wait = 3return = [[4,3],[9,8]]

The edit at 1 books a save for 1 + 3 = 4. The flush also comes at 4, but a save that is due at 4 runs before anything else at 4. So the save runs as [4,3], and the flush finds nothing waiting. In the same way, the save booked at 6 is due at 9 and runs as [9,8] before the cancel at 9.

Example 3

operations = ["flush","edit","edit","cancel","edit"]times = [0,7,7,7,7]values = [0,1,2,0,3]wait = 2return = [[9,3]]

The flush at 0 finds nothing waiting, so nothing happens. At time 7 the first edit books a save for 9, the second replaces it, the cancel drops it, and the last edit books a new save for 9 with value 3. That is the only save: [9,3].

Constraints

  • 1 <= operations.length <= 1000, and times and values have the same length as operations
  • Each operations[i] is "edit", "cancel" or "flush".
  • 0 <= times[i] <= 10^6, and times is sorted in non-decreasing order
  • 0 <= values[i] <= 10^4, and values[i] == 0 when operations[i] is "cancel" or "flush"
  • 1 <= wait <= 10^6

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Lazy Filter over a GeneratorSquarepoint Capital · PHONE SCREEN
  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREEN
  • Search and Format ContactsAdyen · PHONE SCREEN
  • Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
  • Paginate Retained Conversation HistorySierra · PHONE SCREEN
  • Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREEN
  • Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEW
  • Apply Affine Array TransformationsByteDance · PHONE SCREEN
  • Match a Variadic Function SignatureConfluent · PHONE SCREEN
  • Bounded IPv4 FilterAmazon · PHONE SCREEN
See Rippling hiring insights
Saved
class Solution {
    public int[][] autosaveRuns(String[] operations, int[] times, int[] values, int wait) {
        // Write your code here.
    }
}
Checking account…