Skip to content

Commit 31a46d5

Browse files
authored
Create minimum-operations-to-make-the-array-increasing.py
1 parent 2e1c15c commit 31a46d5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def minOperations(self, nums):
6+
"""
7+
:type nums: List[int]
8+
:rtype: int
9+
"""
10+
result = prev = 0
11+
for curr in nums:
12+
if prev < curr:
13+
prev = curr
14+
continue
15+
prev += 1
16+
result += prev-curr
17+
return result

0 commit comments

Comments
 (0)