LeetCode solutions

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

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 7ms, memory 17.2MB, accepted 2025-12-31.

python
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]

Source