cswork / OAOpen practice workspace

CitadelOA #8

Find Valid Sizes (MEX after Increments)

Estimated MediumStatement and editorial — judging is being prepared

Topics (AI-labelled)GreedyHashing

Given an array memoryBlocks[n]. In one operation, choose an index x and increase memoryBlocks[x] by 1. After 0 or more operations, the Valid Size is MEX(memoryBlocks) — the smallest non-negative integer not present. Return the sorted array of all possible Valid Sizes obtainable.

Example: memoryBlocks = [0, 2, 4] → start MEX = 1; after +1 on index 0 → [1, 2, 4] MEX = 0. Answer: [0, 1].

Editorial

Loading solution…