class Solution {
public int projectionArea(int[][] grid) {
int area = 0;
for (int i = 0; i < grid.length; i++) {
for (int j = 0; j < grid[0].length; j++) {
if (grid[i][j] != 0) area++;
}
}
for (int i = 0; i < grid.length; i++) {
int maximum = 0;
for (int j = 0; j < grid[0].length; j++) {
maximum = Math.max(maximum, grid[i][j]);
}
area += maximum;
}
for (int j = 0; j < grid[0].length; j++) {
int maximum = 0;
for (int i = 0; i < grid.length; i++) {
maximum = Math.max(maximum, grid[i][j]);
}
area += maximum;
}
return area;
}
}