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
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
[1,1,1]Expected
32
Input
[1,5,2,4,1]Expected
143
Input
[8]Expected
04
Input
[1,2,3]Expected
05
Input
[3,2,1]Expected
66
Input
[2,2]Expected
1Focus radio
Paused · SomaFM · Fluid