Smallest Missing Non-negative Integer After Operations
You are given a 0-indexed integer array nums and an integer value.
In one operation, you can add or subtract value from any element of nums.
The MEX (minimum excluded) of an array is the smallest missing non-negative integer in it.
Return the maximum MEX of nums after applying the mentioned operation any number of times.
Example 1
Input
nums = [1,-10,7,13,6,8], value = 5Output
4By transforming elements to include 0, 1, 2, and 3, the MEX becomes 4, and it can be shown that 4 is the maximum achievable MEX.
Example 2
Input
nums = [1,-10,7,13,6,8], value = 7Output
2By subtracting 7 from nums[2], the array can include 0, making the MEX 2, and it can be shown that 2 is the maximum achievable MEX.
Constraints
- 1 <= nums.length, value <= 10^5
- -10^9 <= nums[i] <= 10^9