Leetcode Problem 2733. Neither Minimum nor Maximum
2733. Neither Minimum nor Maximum
AI Mock Interview
Leetcode Solutions
Iterative Comparison Approach
Solution Idea
Algorithm Steps
Code Implementation
Complexity Analysis
Check if the length of the array is less than 3. If so, return
-1
.
Initialize two variables to store the minimum and maximum values, setting them both to the first element of the array.
Iterate through the array starting from the second element, updating the minimum and maximum variables as needed.
Iterate through the array again, looking for an element that is not equal to the minimum or maximum values.
If such an element is found, return it.
If no such element is found (which should not happen given the problem constraints), return
-1
.
Sorting Approach
Ask Question
Programming Language
Purpose:
General Question
Debug My Code
image/screenshot of info
(optional)
[+]
Full Screen
Loading...
Get Answer
Suggested Answer
Answer
Full Screen
Copy Answer Code
Loading...