Skip to content

Commit 733a94d

Browse files
committed
Add 1827
1 parent c1a3cd2 commit 733a94d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ https://leetcode.com/jummyegg/
487487
| 1784 | Check if Binary String Has at Most One Segment of Ones | Easy | O(N) | O(1) | Greedy | | |
488488
| 1791 | Find Center of Star Graph | Medium | O(1) | O(1) | Graph | | |
489489
| 1792 | Maximum Average Pass Ratio | Medium | O(N+KlogN) | O(N) | Heap | | |
490+
| 1827 | Minimum Operations to Make the Array Increasing | Easy | O(N) | O(1) | Array, Greedy | | |
490491

491492
# Useful Posts:
492493

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# @lc app=leetcode id=1827 lang=python3
3+
#
4+
# [1827] Minimum Operations to Make the Array Increasing
5+
#
6+
7+
# @lc code=start
8+
9+
10+
class Solution:
11+
# 136 ms, 100%. Time: O(N). Space: O(1)
12+
def minOperations(self, nums: List[int]) -> int:
13+
total = 0
14+
for i in range(1, len(nums)):
15+
if nums[i - 1] >= nums[i]:
16+
total += nums[i - 1] - nums[i] + 1
17+
nums[i] = nums[i - 1] + 1
18+
return total
19+
# @lc code=end

0 commit comments

Comments
 (0)