Make It Increasing

An array is strictly increasing when every next element is greater than the one before it. Write a function min_operations where one operation increases any element by 1. Find the minimum number of such increases needed to make the whole list strictly increasing. Return that number.

Примеры

Ввод
[1, 1, 1]
Вывод
3
Ввод
[1, 5, 2, 4, 1]
Вывод
14
Ввод
[8]
Вывод
0

Нужно реализовать

def min_operations(nums: list[int]) -> int:

Теги

arraymath
PostgreSQLv16

Εδώ θα εμφανιστεί το αποτέλεσμα εκτέλεσης του κώδικα

Visible tests
1
Input
[1,1,1]
Expected3
2
Input
[1,5,2,4,1]
Expected14
3
Input
[8]
Expected0
4
Input
[1,2,3]
Expected0
5
Input
[3,2,1]
Expected6
6
Input
[2,2]
Expected1
Focus radio
Paused · SomaFM · Fluid