Skip to content

Commit a5c74e0

Browse files
authored
Create Solution.java
1 parent db77ba8 commit a5c74e0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
public int projectionArea(int[][] grid) {
3+
int n = grid.length;
4+
int res = 0;
5+
for (int i = 0; i < n; ++i) {
6+
for (int j = 0; j < n; ++j) {
7+
res += grid[i][j] > 0 ? 1 : 0;
8+
}
9+
}
10+
for (int i = 0; i < n; ++i) {
11+
int max = 0;
12+
for (int j = 0; j < n; ++j) {
13+
max = Math.max(max, grid[i][j]);
14+
}
15+
res += max;
16+
}
17+
for (int j = 0; j < n; ++j) {
18+
int max = 0;
19+
for (int i = 0; i < n; ++i) {
20+
max = Math.max(max, grid[i][j]);
21+
}
22+
res += max;
23+
}
24+
return res;
25+
}
26+
}

0 commit comments

Comments
 (0)