mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-06 07:51:41 +08:00
update
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
<ul>
|
||||
|
||||
<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>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
|
||||
|
||||
<pre>
|
||||
|
||||
<strong>Input:</strong> nums = [1,1,1]
|
||||
|
||||
<strong>Output:</strong> 3
|
||||
|
||||
<strong>Explanation:</strong> You can do the following operations:
|
||||
|
||||
1) Increment nums[2], so nums becomes [1,1,<u><strong>2</strong></u>].
|
||||
|
||||
2) Increment nums[1], so nums becomes [1,<u><strong>2</strong></u>,2].
|
||||
|
||||
3) Increment nums[2], so nums becomes [1,2,<u><strong>3</strong></u>].
|
||||
|
||||
</pre>
|
||||
|
||||
|
Reference in New Issue
Block a user