All practice tasks

Coding (Algo)

Missing Result Pages

Hash set · Easy

A search UI knows the total number of result pages and the page numbers already cached. It needs the missing pages in navigation order.

Return page numbers from 1 through total that have not been cached.

Input

Call

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

Input object

{ total:integer, cached:integer[] }

Input rules

  • Duplicate cached numbers are allowed; values outside [1,total] are ignored.

What each field means

  • total — number of result pages, numbered from 1 through total.
  • cached — page numbers already stored locally; duplicates and out-of-range values may occur.

Output

Return value and rules

  • Return every valid page number missing from the cache, in increasing order.
  • Ignore duplicates and cached numbers outside 1..total.
  • Return [] if no valid page is missing.

Constraints

  • 0 <= total <= 100000; 0 <= cached.length <= 100000
  • Cached values are integers in [-1000000,1000000].

Examples

Example 1

{
  "cached": [
    4,
    2,
    2,
    0
  ],
  "total": 5
}

Returns

[
  1,
  3,
  5
]

Example 2

{
  "cached": [],
  "total": 0
}

Returns

[]

Required complexity

O(total + cached.length) time and O(total + cached.length) space

What this task practices

Missing Result Pages 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.