|
| 1 | +# [1827. Minimum Operations to Make the Array Increasing](https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing) |
| 2 | + |
| 3 | +[中文文档](/solution/1800-1899/1827.Minimum%20Operations%20to%20Make%20the%20Array%20Increasing/README.md) |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +<p>You are given an integer array <code>nums</code> (<strong>0-indexed</strong>). In one operation, you can choose an element of the array and increment it by <code>1</code>.</p> |
| 8 | + |
| 9 | +<ul> |
| 10 | + <li>For example, if <code>nums = [1,2,3]</code>, you can choose to increment <code>nums[1]</code> to make <code>nums = [1,<u><b>3</b></u>,3]</code>.</li> |
| 11 | +</ul> |
| 12 | + |
| 13 | +<p>Return <em>the <strong>minimum</strong> number of operations needed to make</em> <code>nums</code> <em><strong>strictly</strong> <strong>increasing</strong>.</em></p> |
| 14 | + |
| 15 | +<p>An array <code>nums</code> is <strong>strictly increasing</strong> if <code>nums[i] < nums[i+1]</code> for all <code>0 <= i < nums.length - 1</code>. An array of length <code>1</code> is trivially strictly increasing.</p> |
| 16 | + |
| 17 | +<p> </p> |
| 18 | +<p><strong>Example 1:</strong></p> |
| 19 | + |
| 20 | +<pre> |
| 21 | +<strong>Input:</strong> nums = [1,1,1] |
| 22 | +<strong>Output:</strong> 3 |
| 23 | +<strong>Explanation:</strong> You can do the following operations: |
| 24 | +1) Increment nums[2], so nums becomes [1,1,<u><strong>2</strong></u>]. |
| 25 | +2) Increment nums[1], so nums becomes [1,<u><strong>2</strong></u>,2]. |
| 26 | +3) Increment nums[2], so nums becomes [1,2,<u><strong>3</strong></u>]. |
| 27 | +</pre> |
| 28 | + |
| 29 | +<p><strong>Example 2:</strong></p> |
| 30 | + |
| 31 | +<pre> |
| 32 | +<strong>Input:</strong> nums = [1,5,2,4,1] |
| 33 | +<strong>Output:</strong> 14 |
| 34 | +</pre> |
| 35 | + |
| 36 | +<p><strong>Example 3:</strong></p> |
| 37 | + |
| 38 | +<pre> |
| 39 | +<strong>Input:</strong> nums = [8] |
| 40 | +<strong>Output:</strong> 0 |
| 41 | +</pre> |
| 42 | + |
| 43 | +<p> </p> |
| 44 | +<p><strong>Constraints:</strong></p> |
| 45 | + |
| 46 | +<ul> |
| 47 | + <li><code>1 <= nums.length <= 5000</code></li> |
| 48 | + <li><code>1 <= nums[i] <= 10<sup>4</sup></code></li> |
| 49 | +</ul> |
| 50 | + |
| 51 | + |
| 52 | +## Solutions |
| 53 | + |
| 54 | +<!-- tabs:start --> |
| 55 | + |
| 56 | +### **Python3** |
| 57 | + |
| 58 | +```python |
| 59 | + |
| 60 | +``` |
| 61 | + |
| 62 | +### **Java** |
| 63 | + |
| 64 | +```java |
| 65 | + |
| 66 | +``` |
| 67 | + |
| 68 | +### **...** |
| 69 | + |
| 70 | +``` |
| 71 | +
|
| 72 | +``` |
| 73 | + |
| 74 | +<!-- tabs:end --> |
0 commit comments