Skip to content

Commit 1a02ecd

Browse files
refactor 883
1 parent e42b44e commit 1a02ecd

File tree

1 file changed

+3
-37
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+3
-37
lines changed

src/main/java/com/fishercoder/solutions/_883.java

+3-37
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,10 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 883. Projection Area of 3D Shapes
5-
*
6-
* On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes.
7-
* Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j).
8-
* Now we view the projection of these cubes onto the xy, yz, and zx planes.
9-
* A projection is like a shadow, that maps our 3 dimensional figure to a 2 dimensional plane.
10-
* Here, we are viewing the "shadow" when looking at the cubes from the top, the front, and the side.
11-
* Return the total area of all three projections.
12-
*
13-
* Example 1:
14-
* Input: [[2]]
15-
* Output: 5
16-
*
17-
* Example 2:
18-
* Input: [[1,2],[3,4]]
19-
* Output: 17
20-
* Explanation:
21-
* Here are the three projections ("shadows") of the shape made with each axis-aligned plane.
22-
*
23-
* Example 3:
24-
* Input: [[1,0],[0,2]]
25-
* Output: 8
26-
*
27-
* Example 4:
28-
* Input: [[1,1,1],[1,0,1],[1,1,1]]
29-
* Output: 14
30-
*
31-
* Example 5:
32-
* Input: [[2,2,2],[2,1,2],[2,2,2]]
33-
* Output: 21
34-
*
35-
* Note:
36-
* 1 <= grid.length = grid[0].length <= 50
37-
* 0 <= grid[i][j] <= 50
38-
* */
393
public class _883 {
404
public static class Solution1 {
41-
/**credit: https://leetcode.com/problems/projection-area-of-3d-shapes/discuss/156726/C%2B%2BJavaPython-Straight-Forward-One-Pass*/
5+
/**
6+
* credit: https://leetcode.com/problems/projection-area-of-3d-shapes/discuss/156726/C%2B%2BJavaPython-Straight-Forward-One-Pass
7+
*/
428
public int projectionArea(int[][] grid) {
439
int n = grid.length;
4410
int area = 0;

0 commit comments

Comments
 (0)