2091. Removing Minimum and Maximum From Array
On This Page
class Solution:
def minimumDeletions(self, nums: List[int]) -> int:
mi = mx = 0
for i, num in enumerate(nums):
if num < nums[mi]:
mi = i
if num > nums[mx]:
mx = i
if mi > mx:
mi, mx = mx, mi
return min(mx + 1, len(nums) - mi, mi + 1 + len(nums) - mx)