贪心思想
class Solution {
public int maxIncreaseKeepingSkyline(int[][] grid) {
int ans =0;
int n = grid.length;
int[] rol = new int[n];
int[] col = new int[n];
for(int i = 0; i < n; i ++){
for(int j = 0; j < n; j ++){
rol[i] = Math.max(rol[i], grid[i][j]);
col[j] = Math.max(col[j], grid[i][j]);
}
}
for(int i = 0; i < n; i ++){
for(int j = 0; j < n; j ++){
ans += Math.min(rol[i], col[j]) - grid[i][j];
}
}
return ans;
}
}