Leetcode 1938 Solution
This article provides solution to leetcode question 1938 (minimum-operations-to-make-the-array-increasing)
Access this page by simply typing in "lcs 1938" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
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