remainder_count
of size value
to store the frequency of each remainder.nums
:
a. If the number is negative, make it non-negative by adding value
enough times.
b. Calculate the remainder of the number modulo value
.
c. Increment the count of this remainder in remainder_count
.mex
to 0.mex % value
in remainder_count
is greater than 0:
a. Decrement the count of mex % value
.
b. Increment mex
by 1.mex
as the maximum MEX that can be achieved.