2500. Delete Greatest Value in Each Row
Easy
Last updated
Easy
Last updated
You are given an m x n
matrix grid
consisting of positive integers.
Perform the following operation until grid
becomes empty:
Delete the element with the greatest value from each row. If multiple such elements exist, delete any of them.
Add the maximum of deleted elements to the answer.
Note that the number of columns decreases by one after each operation.
Return the answer after performing the operations described above.
Example 1:
Example 2:
Constraints:
m == grid.length
n == grid[i].length
1 <= m, n <= 50
1 <= grid[i][j] <= 100