3691. Minimum Operations to Make Columns Strictly Increasing
My accepted Python solution to LeetCode problem 3691, Minimum Operations to Make Columns Strictly Increasing, running in 7ms.
- Difficulty: Easy
- Python
- Runtime 7ms
- Memory 17.6MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 7ms, memory 17.6MB, accepted 2025-12-31.
class Solution:
def minimumOperations(self, grid: List[List[int]]) -> int:
m, n = len(grid), len(grid[0])
operations = 0
for j in range(n):
for i in range(1, m):
if grid[i][j] <= grid[i-1][j]:
diff = grid[i-1][j] - grid[i][j] + 1
grid[i][j] += diff
operations += diff
return operations