Problem:
There are n memory blocks, and the size of the i-th block is given by memoryBlocks[i], where 0 ≤ i < n.
You are allowed to perform the following operation any number of times:
Choose an index x.
Increase memoryBlocks[x] by 1, but only if memoryBlocks[x] < n - 1.
After performing any number of operations, define the Valid Size as the MEX (Minimum Excluded Value), i.e., the smallest non-negative integer not present in the array.
Your task is to return all possible Valid Sizes that can be achieved, sorted in ascending order.
Notes:
The MEX of an array is the smallest non-negative integer not present in it.
Example:
Input:
n = 3
memoryBlocks = [0, 3, 4]
Explanation:
Without any operation, the array is [0, 3, 4], so MEX = 1.
If we choose x = 0 and increment memoryBlocks[0] to 1, the array becomes [1, 3, 4], so MEX = 0.
Thus, the possible Valid Sizes are [0, 1].
Output:
[0, 1]
Function Description:
Complete the function findValidSizes:
findValidSizes(memoryBlocks: List[int]) -> List[int]
Parameters:
memoryBlocks: an array of integers representing memory block sizes
Returns:
A list of integers representing all possible Valid Sizes (MEX values), sorted in ascending order
Constraints:
1 ≤ n ≤ 10^5
0 ≤ memoryBlocks[i] < n