---
# System prepended metadata

title: 2733. Neither Minimum nor Maximum
tags: [Leetcode, Easy, Math]

---

Link: https://leetcode.com/problems/neither-minimum-nor-maximum/description/
## 思路
由于每个数字都是distinct的
所以其实我们只要看前三个数字找出排在中间的那个就好了
可以一个一个比较大小
也可以sort前三个数字
## Code
```python=
class Solution:
    def findNonMinOrMax(self, nums: List[int]) -> int:
        if len(nums)<3: return -1
        currMin, currMax = nums[0], nums[0]
        if nums[1] > nums[0]: currMax = nums[1]
        else: currMin = nums[1]
        if currMin<nums[2]<currMax: return nums[2]
        elif currMin>nums[2]: return currMin
        else: return currMax
```