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.   Example 1: Input: [[2]] Output: 10 Example 2: Input: […
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轴看过去看到的面积值. 把这些面积值…
作者: 负雪明烛 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 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,…
题目如下: 解题思路:分别求出所有立方体的个数,各行的最大值之和,各列的最大值之和.三者相加即为答案. 代码如下: 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 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…
在 N * N 的网格中,我们放置了一些与 x,y,z 三轴对齐的 1 * 1 * 1 立方体. 每个值 v = grid[i][j] 表示 v 个正方体叠放在单元格 (i, j) 上. 现在,我们查看这些立方体在 xy.yz 和 zx 平面上的投影. 投影就像影子,将三维形体映射到一个二维平面上. 在这里,从顶部.前面和侧面看立方体时,我们会看到"影子". 返回所有三个投影的总面积. 示例 1: 输入:[[2]] 输出:5 示例 2: 输入:[[1,2],[3,4]] 输出:17 解…