TheRealSamuel/LeetCodeProblem
0564
1{2 "id": 2836,3 "name": "neither_minimum_nor_maximum",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/neither-minimum-nor-maximum/",6 "date": "2023-06-04 00:00:00",7 "task_description": "Given an integer array `nums` containing **distinct** **positive** integers, find and return **any** number from the array that is neither the **minimum** nor the **maximum** value in the array, or **`-1`** if there is no such number. Return _the selected integer._ **Example 1:** ``` **Input:** nums = [3,2,1,4] **Output:** 2 **Explanation:** In this example, the minimum value is 1 and the maximum value is 4. Therefore, either 2 or 3 can be valid answers. ``` **Example 2:** ``` **Input:** nums = [1,2] **Output:** -1 **Explanation:** Since there is no number in nums that is neither the maximum nor the minimum, we cannot select a number that satisfies the given condition. Therefore, there is no answer. ``` **Example 3:** ``` **Input:** nums = [2,1,3] **Output:** 2 **Explanation:** Since 2 is neither the maximum nor the minimum value in nums, it is the only valid answer. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 100` All values in `nums` are distinct",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [3,2,1,4]",12 "output": "2 "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,2]",17 "output": "-1 "18 },19 {20 "label": "Example 3",21 "input": "nums = [2,1,3]",22 "output": "2 "23 }24 ],25 "private_test_cases": [26 {27 "input": [28 62,29 86,30 92,31 47,32 22,33 36,34 7,35 99,36 96,37 84,38 43,39 48,40 77,41 41,42 76,43 59,44 29,45 32,46 61,47 26,48 6,49 42,50 19,51 18,52 87,53 24,54 97,55 14,56 65,57 98,58 78,59 72,60 80,61 16,62 91,63 21,64 90,65 94,66 55,67 25,68 50,69 51,70 71,71 5,72 52,73 8,74 53,75 67,76 85,77 56,78 54,79 58,80 79,81 88,82 37,83 11,84 17,85 81,86 74,87 89,88 100,89 23,90 44,91 57,92 35,93 66,94 27,95 20,96 45,97 12,98 39,99 38100 ],101 "output": 36102 },103 {104 "input": [105 90,106 66,107 94,108 7,109 88,110 13111 ],112 "output": 88113 },114 {115 "input": [116 5,117 64,118 57,119 98,120 72,121 92,122 99,123 12,124 14,125 18,126 85,127 62,128 4,129 77,130 22,131 81,132 36,133 63,134 30,135 55,136 2,137 27,138 35139 ],140 "output": 57141 },142 {143 "input": [144 49,145 21,146 100,147 37,148 41,149 38,150 57,151 2,152 15,153 81,154 68,155 98,156 34,157 31,158 50,159 14,160 5,161 20,162 91,163 86,164 73,165 83,166 52,167 30,168 94,169 80,170 62,171 53,172 82,173 39,174 32,175 23,176 70,177 36,178 40,179 96,180 93181 ],182 "output": 37183 },184 {185 "input": [186 83,187 61,188 74,189 75,190 22,191 11,192 9,193 6,194 88,195 23,196 51,197 89,198 37,199 96,200 13,201 33,202 49,203 94,204 69,205 78,206 79,207 55,208 39,209 57,210 98,211 21,212 44,213 30,214 65,215 100,216 10,217 87,218 58,219 34,220 56,221 41,222 85,223 45,224 3,225 48,226 59,227 62,228 76,229 92,230 18,231 93,232 54,233 42,234 8,235 7,236 12,237 31,238 17,239 19,240 82,241 4,242 91,243 70,244 14,245 32,246 25,247 16,248 26,249 50,250 66,251 81,252 53,253 77,254 35,255 71,256 99,257 27,258 63,259 5,260 64,261 28,262 43,263 1,264 15,265 36,266 84,267 20,268 29,269 46,270 38,271 95,272 24,273 68,274 97,275 60,276 40277 ],278 "output": 74279 }280 ],281 "haskell_template": "findNonMinOrMax :: [Int] -> Int\nfindNonMinOrMax nums ",282 "ocaml_template": "let findNonMinOrMax (nums: int list) : int = ",283 "scala_template": "def findNonMinOrMax(nums: List[Int]): Int = { \n \n}",284 "java_template": "class Solution {\n public int findNonMinOrMax(int[] nums) {\n \n }\n}",285 "python_template": "class Solution(object):\n def findNonMinOrMax(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "286}