Skip to content

Practice Neither Minimum nor Maximum

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2733
LeetCode Problem

Neither Minimum nor Maximum

Problem Statement

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.

Source: Neither Minimum nor Maximum on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,2,1,4]
Output
2

# Example 2

Input
nums = [1,2]
Output
-1

# Example 3

Input
nums = [2,1,3]
Output
2

Constraints

1 <= nums.length <= 100
1 <= nums[i] <= 100
All values in nums are distinct

Related LeetCode Problems

Practice more problems similar to Neither Minimum nor Maximum.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.