FastPrepResumable Batched Data Loader
Problems/Resumable Batched Data Loader

Resumable Batched Data Loader

Microsoft logoMicrosoft● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft onsite interview. The report asks for a data loader that can resume, but does not give its API or the rules for batching. Here, we use a fixed ordered array of records, saved checkpoint slots and a clear rule for the final batch. Our version is about 65% the same as the reported question.

For this exercise, implement a resumable data loader over the fixed ordered array records. The loader starts before the first record, returns batches of at most batchSize records, and can save and restore its progress. It does not shuffle, restart epochs, or modify records.

Process operations in order. Every operation is a two-integer row:

  • [0,0]: read the next batch. Return up to batchSize consecutive unread records and advance past them. If dropLast is true and fewer than batchSize records remain, discard that tail, become exhausted, and return an empty row. An exhausted loader always returns an empty row.
  • [1,slot]: save a snapshot of the current next-unread position in slot. Overwrite any previous snapshot in that slot and return an empty row.
  • [2,slot]: restore the saved position in that slot and return an empty row. That slot is guaranteed to have been saved earlier.

Saved snapshots do not change when the active loader advances or restores another slot. Saving at the beginning or after exhaustion is valid. Return one int[] row per operation, including empty rows for save, restore, or exhausted reads. A restore may intentionally cause previously returned records to appear again.

Function

resumeBatches(records: int[], batchSize: int, dropLast: boolean, operations: int[][]) → int[][]

Examples

Example 1

records = [10,20,30,40,50]batchSize = 2dropLast = falseoperations = [[0,0],[1,7],[0,0],[2,7],[0,0],[0,0],[0,0]]return = [[10,20],[],[30,40],[],[30,40],[50],[]]

Slot 7 captures the next unread record, 30. Restoring it repeats [30,40]; the final partial batch is kept and the next read is empty.

Example 2

records = [1,2,3,4,5]batchSize = 3dropLast = trueoperations = [[1,0],[0,0],[1,1],[0,0],[2,1],[0,0],[2,0],[0,0]]return = [[],[1,2,3],[],[],[],[],[],[1,2,3]]

The two-record tail is dropped. Slot 1 resumes at that tail and still yields no batch; slot 0 restores the initial position.

Example 3

records = [-2,-2,7]batchSize = 1dropLast = falseoperations = [[1,4],[0,0],[1,4],[0,0],[2,4],[0,0],[0,0]]return = [[],[-2],[],[-2],[],[-2],[7]]

Saving again overwrites slot 4 with the position after the first record. Duplicate record values do not identify progress.

Constraints

  • 0 <= records.length <= 200 and 1 <= batchSize <= 200.
  • Record values are integers in -10^6..10^6; duplicates are allowed.
  • 0 <= operations.length <= 200; each row has exactly two integers and follows one of the three operation forms.
  • Checkpoint slot IDs are in 0..100; every restore references a previously saved slot.
  • The total number of record values emitted across all returned rows is at most 4000. Save and restore rows contain no record values.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Escape Room LeaderboardPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Insert, Delete, And Get Random In Constant TimeAmazon · ONSITE INTERVIEW
  • Insert, Delete, And Get Random In Constant TimeGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Future-Effective Employee SalaryRippling · ONSITE INTERVIEWRippling interview questions
  • Insert, Delete, and Get Random in Constant TimeBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Constant-Time Key Store Built on ArraysPatreon · ONSITE INTERVIEWPatreon interview questions
  • Randomized Collection with Duplicate ValuesOkta · ONSITE INTERVIEWOkta interview questions
  • Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int[][] resumeBatches(int[] records, int batchSize, boolean dropLast, int[][] operations) {
        // Write your code here.
    }
}
Checking account…