Skip to content

Practice Smallest Missing Non-negative Integer After Operations

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2598
LeetCode Problem

Smallest Missing Non-negative Integer After Operations

Problem Statement

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.

Source: Smallest Missing Non-negative Integer After Operations on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,-10,7,13,6,8], value = 5
Output
4

# Example 2

Input
nums = [1,-10,7,13,6,8], value = 7
Output
2

Constraints

1 <= nums.length, value <= 10^5
-10^9 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Smallest Missing Non-negative Integer After Operations.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.