最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

leetcode892. Surface Area of 3D Shapes

2022-02-14 15:29 作者:您是打尖兒還是住店呢  | 我要投稿

You are given an?n x n?grid?where you have placed some?1 x 1 x 1?cubes. Each value?v = grid[i][j]?represents a tower of?v?cubes placed on top of cell?(i, j).

After placing these cubes, you have decided to glue any directly adjacent cubes to each other, forming several irregular 3D shapes.

Return?the total surface area of the resulting shapes.

Note:?The bottom face of each shape counts toward its surface area.

?

Example 1:

Input: grid = [[1,2],[3,4]]Output: 34

Example 2:

Input: grid = [[1,1,1],[1,0,1],[1,1,1]]Output: 32

Example 3:

Input: grid = [[2,2,2],[2,1,2],[2,2,2]]Output: 46

?

Constraints:

  • n == grid.length == grid[i].length

  • 1 <= n <= 50

  • 0 <= grid[i][j] <= 50

Accepted

27,339

Submissions

44,530



橫排重復(fù)(i),縱排重復(fù)(j),上下重復(fù)(i,j)>1時候的面算出來,然后正方體的總數(shù)*6-重復(fù)的面就能得出;

Success

Details?

Runtime:?3 ms, faster than?83.66%?of?Java?online submissions for?Surface Area of 3D Shapes.

Memory Usage:?45 MB, less than?7.78%?of?Java?online submissions for?Surface Area of 3D Shapes.


leetcode892. Surface Area of 3D Shapes的評論 (共 條)

分享到微博請遵守國家法律
绍兴市| 尉犁县| 安福县| 嵊州市| 湟源县| 开远市| 仁怀市| 铜山县| 确山县| 绥阳县| 和顺县| 浮梁县| 南召县| 安图县| 乐清市| 福安市| 分宜县| 沅江市| 杨浦区| 富锦市| 五常市| 溧阳市| 北宁市| 察雅县| 咸丰县| 苏尼特右旗| 滕州市| 寿宁县| 烟台市| 延津县| 托里县| 沭阳县| 平泉县| 博爱县| 拉孜县| 塘沽区| 永定县| 太湖县| 尼勒克县| 苍南县| 呼和浩特市|