---
# System prepended metadata

title: 2500. Delete Greatest Value in Each Row
tags: [Leetcode, Easy]

---

# 2500. Delete Greatest Value in Each Row
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/delete-greatest-value-in-each-row/description/
## Code
```java=
class Solution {
    public int deleteGreatestValue(int[][] grid) {
        int m = grid.length, n = grid[0].length;
        for(int i=0; i<m; i++) Arrays.sort(grid[i]);
        int ans = 0;
        for(int j=0; j<n; j++){
            int max = 0;
            for(int i=0; i<m; i++){
                max = Math.max(max, grid[i][j]);
            }
            ans += max;
        }
        return ans;
    }
}
```