Algorithm · Citadel · Medium
You are given an integer array memoryBlocks with n elements, where every value satisfies 0 ≤ memoryBlocks[i] < n. You are allowed to apply at most one modification to the array: pick a single index i whose value satisfies memoryBlocks[i] < n - 1, and add 1 to that element. Leaving the array untouched (applying no modification) is also allowed. The MEX (minimum excluded value) of an array is defined as the smallest non-negative integer that does not appear anywhere in the…