Leetcode in Java && Oracle
423 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-12-22_00-42-57.png
30.2 KB
Runtime 3 ms Beats 99.42%
Memory 42.1 MB Beats 97.7%

#N2500. Delete Greatest Value in Each Row
problem link
#solution
class Solution {
public int deleteGreatestValue(int[][] grid) {
int m=grid.length, n=grid[0].length;
int sum=0, max=0;
for(int i=0; i<m; i++) Arrays.sort(grid[i]);

for(int i=n-1; i>=0; i--){
max=0;
for(int j=0; j<m; j++){
if(grid[j][i]>max) max=grid[j][i];
}
sum+=max;
}
return sum;
}
}
3