# 1827. Minimum Operations to Make the Array Increasing
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing/
## 思路 $O(N)$ $O(1)$
Traverse the input array, compare each element $cur$ with the modified previous element $prev$; If $cur$ > $prev$, update $prev$ to the value of $cur$ for the prospective comparison in the next iteration; otherwise, we need to increase $cur$ to at least $prev$ + 1 to make the array strictly increasing; in this case, update $prev$ by increment of 1.
## Code
```java=
class Solution {
public int minOperations(int[] nums) {
int ans = 0;
int prev = nums[0];
for(int i = 1;i < nums.length;i++){
if(nums[i]<prev+1){
ans += (prev+1)-nums[i];
prev = prev+1;
}
else{
prev = nums[i];
}
}
return ans;
}
}
```