FastPrepFill Missing Values in a Fixed-Step Sequence
Problems/Fill Missing Values in a Fixed-Step Sequence

Fill Missing Values in a Fixed-Step Sequence

Datadog logoDatadog● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report provides fixed-step sequence examples and clarifies that existing gaps respect the supplied step. The callable interface, singleton case, and bounds are supplied for practice. The core task matches the report at about 95%.

Insert missing integers into values so that every consecutive output gap equals step.

Keep all given values. Return the complete sequence in increasing order, beginning at the first given value and ending at the last. Do not add values outside this range. The input is already sorted, and all existing gaps are positive multiples of step. A single given value is returned unchanged.

Function

fillMissingValues(values: int[], step: int) → int[]

Examples

Example 1

values = [5,10,20]step = 5return = [5,10,15,20]

The gap from 10 to 20 is two steps of 5, so insert 15. The other gap already has the required size.

Example 2

values = [5,25,35]step = 10return = [5,15,25,35]

Insert 15 between 5 and 25. Each consecutive output gap is then 10.

Example 3

values = [-3]step = 4return = [-3]

A single given value has no gap to fill, so return [-3].

Constraints

  • 1 <= values.length <= 200
  • -1000000 <= values[i] <= 1000000
  • 1 <= step <= 1000000
  • The values are strictly increasing, and each consecutive gap is a positive multiple of step.
  • (values[values.length - 1] - values[0]) / step <= 1000

More Datadog problems

  • Query Log MatchPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Delete a Filesystem TreePHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Grouped-Query Attention Forward PassPHONE SCREEN · Seen Jun 2026
All Datadog interview questionsSee Datadog hiring insights
Saved
public int[] fillMissingValues(int[] values, int step) {
    // Write your code here.
}
Checking account…