Back to course home
0% completed
Removing Minimum and Maximum From Array (medium)
Problem Statement
Determine the minimum
number of deletions
required to remove the smallest and the largest elements from an array of integers.
In each deletion
, you are allowed to remove either the first (leftmost)
or the last (rightmost)
element of the array.
Examples

Example 1:
 Input:
[3, 2, 5, 1, 4]
 Expected Output:
3
 Justification: The smallest element is
1
and the largest is5
. Removing4
,1
, and then5
(or5
,4
, and then1
) in three moves is the most efficient strategy.
 Input:

Example 2:
 Input:
[7, 5, 6, 8, 1]
 Input:
.....
.....
.....
Like the course? Get enrolled and start learning!