1
class Solution {
2
public int projectionArea(int[][] grid) {
3
int totalArea = 0;
4

5
for (int[] row : grid) {
6
int max = row[0];
7
for (int c : row) {
8
if (max < c) {
9
max = c;
10
}
11
if (c != 0) {
12
totalArea += 1;
13
}
14
}
15
totalArea += max;
16
}
17

18
for (int c = 0; c < grid[0].length; c++) {
19
int max = grid[0][c];
20
for (int row = 0; row < grid.length; row++) {
21
if (max < grid[row][c]) {
22

23
max = grid[row][c];
24
}
25
}
26
totalArea += max;
27
}
28
return totalArea;
29
}
30
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0