FastPrepDynamic Batch Completion Times
Problems/Dynamic Batch Completion Times

Dynamic Batch Completion Times

Ambience Healthcare logoAmbience Healthcare● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Ambience Healthcare technical-phone report asks for dynamic batching of a list of sequences so a new subtask is scheduled immediately whenever one finishes, and compares it with LeetCode 1882 while noting extra edge cases. Identical batch slots, all-at-once arrival, duration as sequence length, FIFO waiting order, and completion-time output are explicit authored practice assumptions that make the reported scheduler executable. The judged contract matches the recoverable source at about 76%.

All generation sequences are waiting at time 0 in input order. A dynamic batch has batchSize identical slots. A sequence of length L occupies one slot for L time units.

Whenever a slot becomes free, immediately assign the next waiting sequence. If several slots become free together, use the smaller slot index first. Return each sequence’s completion time in input order.

Function

dynamicBatchCompletionTimes(sequenceLengths: int[], batchSize: int) → int[]

Examples

Example 1

sequenceLengths = [2,1,3]batchSize = 2return = [2,1,4]

The length-1 sequence finishes first; the third sequence immediately takes that slot.

Example 2

sequenceLengths = [3,3,3]batchSize = 1return = [3,6,9]

One slot processes every sequence serially.

Example 3

sequenceLengths = [1,1,1,1]batchSize = 2return = [1,1,2,2]

Two sequences finish at each time step.

Constraints

  • 1 <= sequenceLengths.length <= 100000.
  • 1 <= batchSize <= sequenceLengths.length.
  • 1 <= sequenceLengths[i] <= 100000.

More Ambience Healthcare problems

  • Autoregressive Token GenerationPHONE SCREEN · Seen Sep 2026
See Ambience Healthcare hiring insights
Saved
class Solution {
    public int[] dynamicBatchCompletionTimes(int[] sequenceLengths, int batchSize) {
        // Schedule waiting sequences whenever a batch slot frees.
    }
}
Checking account…