cswork / OA打开练习工作台

CitadelOA #8

Find Valid Sizes (MEX after Increments)

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)贪心调度哈希计数

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].