Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Removals to Make Mountain Array

Minimum Number of Removals to Make Mountain Array asks you to remove as few values as possible so the remaining array strictly rises to one peak, then strictly falls.

Statement

An array arr is defined as a mountain array if and only if:

  • arr.length ≥3\geq 3

  • There exists some index i with 0<i<0 < i < arr.length −1- 1 such that:

    • arr[0] < arr[1] < …\dots < arr[i - 1] < arr[i]

    • arr[i] > arr[i + 1] > …\dots > arr[arr.length - 1]

Given an integer array nums, return the minimum number of elements that must be removed to make nums a mountain array.

Constraints:

  • 3≤3 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • It is guaranteed that you can make a mountain array out of nums.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Removals to Make Mountain Array

Minimum Number of Removals to Make Mountain Array asks you to remove as few values as possible so the remaining array strictly rises to one peak, then strictly falls.

Statement

An array arr is defined as a mountain array if and only if:

  • arr.length ≥3\geq 3

  • There exists some index i with 0<i<0 < i < arr.length −1- 1 such that:

    • arr[0] < arr[1] < …\dots < arr[i - 1] < arr[i]

    • arr[i] > arr[i + 1] > …\dots > arr[arr.length - 1]

Given an integer array nums, return the minimum number of elements that must be removed to make nums a mountain array.

Constraints:

  • 3≤3 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • It is guaranteed that you can make a mountain array out of nums.