Leetcode 1938 Solution

This article provides solution to leetcode question 1938 (minimum-operations-to-make-the-array-increasing)

https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing

Solution

class Solution:
    def minOperations(self, nums: List[int]) -> int:
        level = 0
        ans = 0
        for num in nums:
            target = max(level, num)
            ans += target - num
            level = target + 1
        return ans