Tap here to switch tabs
Problem
Submissions

Problem: Removing Minimum and Maximum From Array

med
30 min
Try to solve the Removing Minimum and Maximum From Array problem.

Statement

You are given a 00 indexed integer array nums consisting of distinct elements.

In a single operation, you can remove either the first element or the last element of nums.

Return the minimum number of deletions needed to remove both the minimum element and the maximum element from the array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −105≤-10^5 \leq nums[i] ≤105\leq 10^5

  • The integers in nums are distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Removing Minimum and Maximum From Array

med
30 min
Try to solve the Removing Minimum and Maximum From Array problem.

Statement

You are given a 00 indexed integer array nums consisting of distinct elements.

In a single operation, you can remove either the first element or the last element of nums.

Return the minimum number of deletions needed to remove both the minimum element and the maximum element from the array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −105≤-10^5 \leq nums[i] ≤105\leq 10^5

  • The integers in nums are distinct.