FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3081,3 "name": "minimum-array-length-after-pair-removals",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/minimum-array-length-after-pair-removals/",6 "date": "2023-09-02",7 "task_description": "Given an integer array `num` sorted in non-decreasing order. You can perform the following operation any number of times: Choose **two** indices, `i` and `j`, where `nums[i] < nums[j]`. Then, remove the elements at indices `i` and `j` from `nums`. The remaining elements retain their original order, and the array is re-indexed. Return the **minimum** length of `nums` after applying the operation zero or more times. **Example 1:** **Input:** nums = [1,2,3,4] **Output:** 0 **Explanation:** **Example 2:** **Input:** nums = [1,1,2,2,3,3] **Output:** 0 **Explanation:** **Example 3:** **Input:** nums = [1000000000,1000000000] **Output:** 2 **Explanation:** Since both numbers are equal, they cannot be removed. **Example 4:** **Input:** nums = [2,3,4,4,4] **Output:** 1 **Explanation:** **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i] <= 109` `nums` is sorted in **non-decreasing** order.",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [1,2,3,4]",12 "output": "0 "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,1,2,2,3,3]",17 "output": "0 "18 },19 {20 "label": "Example 3",21 "input": "nums = [1000000000,1000000000]",22 "output": "2 "23 },24 {25 "label": "Example 4",26 "input": "nums = [2,3,4,4,4]",27 "output": "1 "28 }29 ],30 "constraints": [31 "Choose two indices, i and j, where nums[i] < nums[j].",32 "Then, remove the elements at indices i and j from nums. The remaining elements retain their original order, and the array is re-indexed.",33 "1 <= nums.length <= 105",34 "1 <= nums[i] <= 109",35 "nums is sorted in non-decreasing order."36 ],37 "python_template": "class Solution(object):\n def minLengthAfterRemovals(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n ",38 "java_template": "class Solution {\n public int minLengthAfterRemovals(List<Integer> nums) {\n \n }\n}",39 "metadata": {40 "func_name": "minLengthAfterRemovals"41 }42}