FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 2661,3 "name": "smallest-missing-non-negative-integer-after-operations",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/smallest-missing-non-negative-integer-after-operations/",6 "date": "2023-03-12",7 "task_description": "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`. For example, if `nums = [1,2,3]` and `value = 2`, you can choose to subtract `value` from `nums[0]` to make `nums = [-1,2,3]`. The MEX (minimum excluded) of an array is the smallest missing **non-negative** integer in it. For example, the MEX of `[-1,2,3]` is `0` while the MEX of `[1,0,3]` is `2`. 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 = 5 **Output:** 4 **Explanation:** One can achieve this result by applying the following operations: - Add value to nums[1] twice to make nums = [1,**0**,7,13,6,8] - Subtract value from nums[2] once to make nums = [1,0,**2**,13,6,8] - Subtract value from nums[3] twice to make nums = [1,0,2,**3**,6,8] The MEX of nums is 4. It can be shown that 4 is the maximum MEX we can achieve. ``` **Example 2:** ``` **Input:** nums = [1,-10,7,13,6,8], value = 7 **Output:** 2 **Explanation:** One can achieve this result by applying the following operation: - subtract value from nums[2] once to make nums = [1,-10,**0**,13,6,8] The MEX of nums is 2. It can be shown that 2 is the maximum MEX we can achieve. ``` **Constraints:** `1 <= nums.length, value <= 105` `-109 <= nums[i] <= 109`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [1,-10,7,13,6,8], value = 5",12 "output": "4 "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,-10,7,13,6,8], value = 7",17 "output": "2 "18 }19 ],20 "constraints": [21 "For example, if nums = [1,2,3] and value = 2, you can choose to subtract value from nums[0] to make nums = [-1,2,3].",22 "For example, the MEX of [-1,2,3] is 0 while the MEX of [1,0,3] is 2.",23 "1 <= nums.length, value <= 105",24 "-109 <= nums[i] <= 109"25 ],26 "python_template": "class Solution(object):\n def findSmallestInteger(self, nums, value):\n \"\"\"\n :type nums: List[int]\n :type value: int\n :rtype: int\n \"\"\"\n ",27 "java_template": "class Solution {\n public int findSmallestInteger(int[] nums, int value) {\n \n }\n}",28 "metadata": {29 "func_name": "findSmallestInteger"30 }31}