-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7695b5
commit c5d42f8
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
1671-minimum-number-of-removals-to-make-mountain-array/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<h2><a href="https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array/?envType=daily-question&envId=2024-10-30">1671. Minimum Number of Removals to Make Mountain Array</a></h2><h3>Hard</h3><hr><p>You may recall that an array <code>arr</code> is a <strong>mountain array</strong> if and only if:</p> | ||
|
||
<ul> | ||
<li><code>arr.length >= 3</code></li> | ||
<li>There exists some index <code>i</code> (<strong>0-indexed</strong>) with <code>0 < i < arr.length - 1</code> such that: | ||
<ul> | ||
<li><code>arr[0] < arr[1] < ... < arr[i - 1] < arr[i]</code></li> | ||
<li><code>arr[i] > arr[i + 1] > ... > arr[arr.length - 1]</code></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
|
||
<p>Given an integer array <code>nums</code>, return <em>the <strong>minimum</strong> number of elements to remove to make </em><code>nums<em></em></code><em> </em><em>a <strong>mountain array</strong>.</em></p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> nums = [1,3,1] | ||
<strong>Output:</strong> 0 | ||
<strong>Explanation:</strong> The array itself is a mountain array so we do not need to remove any elements. | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> nums = [2,1,1,5,6,2,3,1] | ||
<strong>Output:</strong> 3 | ||
<strong>Explanation:</strong> One solution is to remove the elements at indices 0, 1, and 5, making the array nums = [1,5,6,3,1]. | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>3 <= nums.length <= 1000</code></li> | ||
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li> | ||
<li>It is guaranteed that you can make a mountain array out of <code>nums</code>.</li> | ||
</ul> |