You are given an m $ imes$ n matrix grid consisting of positive integers.
Perform the following process repeatedly until grid becomes empty:
Delete the maximum value from each row. If a row contains multiple copies of the maximum value, delete any one of them.
Identify the greatest value among all the elements removed across every row in the current step.
Add this value to a running total.
Return the final sum obtained after all elements are removed from grid.
Constraints:
m grid.length
n grid[i].length
m, n
grid[i][j]
You are given an m $ imes$ n matrix grid consisting of positive integers.
Perform the following process repeatedly until grid becomes empty:
Delete the maximum value from each row. If a row contains multiple copies of the maximum value, delete any one of them.
Identify the greatest value among all the elements removed across every row in the current step.
Add this value to a running total.
Return the final sum obtained after all elements are removed from grid.
Constraints:
m grid.length
n grid[i].length
m, n
grid[i][j]