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-15_01-55-30.png
43.1 KB
Runtime 2 ms Beats 81.30% Memory 41.9 MB Beats 88.62%


#N883. Projection Area of 3D Shapes
problem link
#solution
class Solution {
public int projectionArea(int[][] grid) {
int xy=0, yz=0, zx=0, max=0;

for(int i=0; i<grid.length; i++){
for(int j=0; j<grid[0].length; j++){
if(grid[i][j]!=0) xy++;
max=Math.max(max, grid[i][j]);
}
zx+=max;
max=0;
}
for(int i=0; i<grid[0].length; i++){
for(int j=0; j<grid.length; j++)
max=Math.max(max, grid[j][i]);
yz+=max;
max=0;
}

return xy+yz+zx;
}
}
👍5