// 1827. Minimum Operations to Make the Array Increasing
class Solution {
public int minOperations(int[] nums) {
int len = nums.length;
int ans = 0;
int current = nums[0];
for (int i = 1; i < len; ++i) {
++current;
if (nums[i] < current) {
ans += current - nums[i];
} else {
current = nums[i];
}
}
return ans;
}
}
学习笔记: 这是一道简单题,数组题。 就是需要一直递增,遇到大的就很自然,小的就要提升。
LeetCode is the best platform to help you enhance your skills, expand your knowledge and prepare for technical interviews.