All practice tasks

Coding (Algo)

Missing Upload Sequence

Arithmetic · Easy

An upload batch should contain every sequence number from 0 through n exactly once, but one record is missing.

Return the missing sequence number without sorting the batch.

Input

Call

  • Implement solve(input) and return its result. Do not print from solve.

Input object

{ received:integer[] }

Input rules

  • For n=received.length, values are distinct members of [0,n].

What each field means

  • received — distinct sequence numbers in arbitrary order.
  • If there are n received values, exactly one number from 0 through n is missing.

Output

Return value and rules

  • Return the missing integer.
  • Do not sort or mutate the batch.
  • An empty batch returns 0.

Constraints

  • 0 <= received.length <= 100000
  • Input may be in any order and must not be mutated.

Examples

Example 1

{
  "received": [
    3,
    0,
    1
  ]
}

Returns

2

Example 2

{
  "received": []
}

Returns

0

Required complexity

O(n) time and O(1) auxiliary space

What this task practices

Missing Upload Sequence is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as easy difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.