LeetCode solutions

2585. Delete Greatest Value in Each Row

My accepted Python solution to LeetCode problem 2585, Delete Greatest Value in Each Row, running in 4ms.

  • Difficulty: Easy
  • Python
  • Runtime 4ms
  • Memory 17.5MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 4ms, memory 17.5MB, accepted 2026-01-01.

python
class Solution:
    def deleteGreatestValue(self, grid: List[List[int]]) -> int:
        for row in grid:
            row.sort()
        result = 0
        for col in range(len(grid[0])):
            max_val = max(row[col] for row in grid)
            result += max_val
        return result

Source