Skip to content

Commit

Permalink
leetcode min ops to make cols strictly increasing
Browse files Browse the repository at this point in the history
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
  • Loading branch information
ferhatelmas committed Jan 7, 2025
1 parent 3770d4a commit f22028a
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import List


class Solution:
def minimumOperations(self, grid: List[List[int]]) -> int:
total = 0
for col in map(list, zip(*grid)):
prev = -1
for i, e in enumerate(col):
if i == 0:
prev = e
continue
if e > prev:
prev = e
else:
total += prev - e + 1
prev += 1
return total

0 comments on commit f22028a

Please sign in to comment.