Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
minimize-the-maximum-adjacent-element-difference.json38 linesDownload Raw Back to root
1{2  "id": 3658,3  "name": "minimize-the-maximum-adjacent-element-difference",4  "difficulty": "Hard",5  "link": "https://leetcode.com/problems/minimize-the-maximum-adjacent-element-difference/",6  "date": "2024-11-10",7  "task_description": "You are given an array of integers `nums`. Some values in `nums` are **missing** and are denoted by -1. You can choose a pair of **positive** integers `(x, y)` **exactly once** and replace each **missing** element with _either_ `x` or `y`. You need to **minimize**** **the** maximum** **absolute difference** between _adjacent_ elements of `nums` after replacements. Return the **minimum** possible difference. **Example 1:** **Input:** nums = [1,2,-1,10,8] **Output:** 4 **Explanation:** By choosing the pair as `(6, 7)`, nums can be changed to `[1, 2, 6, 10, 8]`. The absolute differences between adjacent elements are: `|1 - 2| == 1` `|2 - 6| == 4` `|6 - 10| == 4` `|10 - 8| == 2` **Example 2:** **Input:** nums = [-1,-1,-1] **Output:** 0 **Explanation:** By choosing the pair as `(4, 4)`, nums can be changed to `[4, 4, 4]`. **Example 3:** **Input:** nums = [-1,10,-1,8] **Output:** 1 **Explanation:** By choosing the pair as `(11, 9)`, nums can be changed to `[11, 10, 9, 8]`. **Constraints:** `2 <= nums.length <= 105` `nums[i]` is either -1 or in the range `[1, 109]`.",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [1,2,-1,10,8]",12      "output": "4 "13    },14    {15      "label": "Example 2",16      "input": "nums = [-1,-1,-1]",17      "output": "0 "18    },19    {20      "label": "Example 3",21      "input": "nums = [-1,10,-1,8]",22      "output": "1 "23    }24  ],25  "constraints": [26    "|1 - 2| == 1",27    "|2 - 6| == 4",28    "|6 - 10| == 4",29    "|10 - 8| == 2",30    "2 <= nums.length <= 105",31    "nums[i] is either -1 or in the range [1, 109]."32  ],33  "python_template": "class Solution(object):\n    def minDifference(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: int\n        \"\"\"\n        ",34  "java_template": "class Solution {\n    public int minDifference(int[] nums) {\n        \n    }\n}",35  "metadata": {36    "func_name": "minDifference"37  }38}