AO
Back

All Achievable MEX Values After Increment Operations

OAAsync OALast reported October 2025Low Frequency

Problem Overview

There are n memory blocks, and the size of the i-th block is memoryBlocks[i] (0 ≤ i < n).

The operation: select an index x and increase memoryBlocks[x] by 1, but only if memoryBlocks[x] is less than n - 1.

The MEX (minimum excluded value) of the array is the smallest non-negative integer not present in it; the prompt calls it a Valid Size. Return every Valid Size that can be reached, sorted in ascending order.

Complete findValidSizes(memoryBlocks), which returns int[].

Example (as posted)

n = 3, memoryBlocks = [0, 3, 4]

No operation:                    MEX = 1
x = 0, 0 -> 1 gives [1, 3, 4]:   MEX = 0

answer = [0, 1]

Constraints (as posted)

  • 1 ≤ n ≤ 10^5
  • 0 ≤ memoryBlocks[i] < n

Clarify before coding

  • How many operations? The prompt says the operation "can be performed on memoryBlocks one time", then defines a Valid Size as the MEX "after any number of operations". The example lists only doing nothing and one increment. The readings differ on repeated values: on [0, 0], the at-most-one reading gives [1, 2] (1 by doing nothing, 2 by one increment), while any number of increments, or increasing each block at most once, also reaches 0. Ask which is meant.
  • Values of n or more: the constraint says every value is below n, but the posted example has 3 and 4 with n = 3. Such a block can never be increased.

What Reports Emphasize

Why people fail: The one reporting candidate did not solve this problem, the second of two in the OA; they say it took ten minutes to understand one problem's wording.

Practice

Write your own against 9 test cases, or read the worked solution — approach, complexity, and code that runs.

Prepping for Citadel with friends?

Send them this page. It is free to read, no account needed.

More Citadel Questions

Free preview

Every question in the Citadel catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 62 Citadel questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Citadel · OA · Reported 1× across candidate reports
Is this helpful?