2836. Neither Minimum nor Maximum
My accepted Python solution to LeetCode problem 2836, Neither Minimum nor Maximum, running in 7ms.
- Difficulty: Easy
- Python
- Runtime 7ms
- Memory 17.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 7ms, memory 17.2MB, accepted 2025-12-31.
class Solution:
def findNonMinOrMax(self, nums: List[int]) -> int:
if len(nums) < 3:
return -1
# Sort first 3 elements and return the middle one
first_three = sorted(nums[:3])
return first_three[1]