题目要求 On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes. Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j). Now we view the projection of these cubes onto the xy, yz,…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 数学计算 日期 题目地址:https://leetcode.com/problems/projection-area-of-3d-shapes/description/ 题目描述 On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, an…
On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes. Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j). Now we view the projection of these cubes onto the xy, yz, and…
题目要求 On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j). Return the total surface area of the resulting shapes. 题目分析及思路 给定一个N*N网格,在其上放置1*1*1的小方块,二维数组的值即为当前位置的高度,要求…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/surface-area-of-3d-shapes/description/ 题目描述 On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower o…
problem 883. Projection Area of 3D Shapes 参考 1. Leetcode_easy_883. Projection Area of 3D Shapes; 完…
问题 NxN个格子中,用1x1x1的立方体堆叠,grid[i][j]表示坐标格上堆叠的立方体个数,求三视图面积. Input: [[1,2],[3,4]] Output: 17 Explanation: 见下图 思路 对于俯视图,只要一个格子有值,面积值就加1. 对于正视图(面朝x轴),对于某一个x,在y轴方向上拥有的最高grid值,表示,该x顺着y轴看过去看到的面积值. 对于侧视图(面朝y轴),对于某一个y,在x轴方向上拥有的最高grid值,表示,该y顺着y轴看过去看到的面积值. 把这些面积值…
On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes. Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j). Now we view the projection of these cubes onto the xy, yz, and…
题目如下: 解题思路:分别求出所有立方体的个数,各行的最大值之和,各列的最大值之和.三者相加即为答案. 代码如下: class Solution(object): def projectionArea(self, grid): """ :type grid: List[List[int]] :rtype: int """ front = [0] * len(grid) side = [0] * len(grid) top = 0 for i in…
On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j). Return the total surface area of the resulting shapes. Example 1: Input: [[2]] Output: 10 Example 2: Input: [[1…