JAVA_Surface Area of 3D Shapes_LeetCode 892


JAVA_Surface Area of 3D Shapes_LeetCode 892

JAVA_Surface Area of 3D Shapes_LeetCode 892 풀이 class Solution { public int surfaceArea(int[][] grid) { int area = 0; for(int i = 0; i < grid.length; i++){ for(int j = 0;j < grid.length;j++){ if(grid[i][j] > 0) area += grid[i][j] * 4 + 2; if(i > 0) area -= Math.min(grid[i][j], grid[i-1][j]) * 2; if(j > 0) area -= Math.min(grid[i][j], grid[i][j-1]) * 2; } } return area; } } * 출처 Surface Area of 3D Shapes - LeetCode Can you solve this real interview question? Surface Area of 3D Shapes - You are giv...


#JAVA #JAVA_LeetCode892 #JAVA_SurfaceAreaof3DShapes #JAVA_SurfaceAreaof3DShapes_LeetCode892 #SurfaceAreaof3DShapes_LeetCode892

원문링크 : JAVA_Surface Area of 3D Shapes_LeetCode 892