Class Solution
java.lang.Object
g0801_0900.s0892_surface_area_of_3d_shapes.Solution
892 - Surface Area of 3D Shapes.<p>Easy</p>
<p>You are given an <code>n x n</code> <code>grid</code> where you have placed some <code>1 x 1 x 1</code> cubes. Each value <code>v = grid[i][j]</code> represents a tower of <code>v</code> cubes placed on top of cell <code>(i, j)</code>.</p>
<p>After placing these cubes, you have decided to glue any directly adjacent cubes to each other, forming several irregular 3D shapes.</p>
<p>Return <em>the total surface area of the resulting shapes</em>.</p>
<p><strong>Note:</strong> The bottom face of each shape counts toward its surface area.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/01/08/tmp-grid2.jpg" alt="" /></p>
<p><strong>Input:</strong> grid = [[1,2],[3,4]]</p>
<p><strong>Output:</strong> 34</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/01/08/tmp-grid4.jpg" alt="" /></p>
<p><strong>Input:</strong> grid = [[1,1,1],[1,0,1],[1,1,1]]</p>
<p><strong>Output:</strong> 32</p>
<p><strong>Example 3:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/01/08/tmp-grid5.jpg" alt="" /></p>
<p><strong>Input:</strong> grid = [[2,2,2],[2,1,2],[2,2,2]]</p>
<p><strong>Output:</strong> 46</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == grid.length == grid[i].length</code></li>
<li><code>1 <= n <= 50</code></li>
<li><code>0 <= grid[i][j] <= 50</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
surfaceArea
public int surfaceArea(int[][] grid)
-