首页 > 其他 > 详细

883. 三维形体投影面积

时间:2020-04-29 19:19:54      阅读:77      评论:0      收藏:0      [点我收藏+]
 1 class Solution 
 2 {
 3 public:
 4     int projectionArea(vector<vector<int>>& grid) 
 5     {
 6         int m = grid.size(),n = grid[0].size();
 7         int res = 0;
 8         for(int i = 0;i < m;i ++)
 9         {
10             int temp = 0;
11             for(int j = 0;j < n;j ++)
12             {
13                 if(grid[i][j]) res ++;
14                 temp = max(temp,grid[i][j]);
15             }
16             res += temp;
17         }
18 
19         for(int j = 0;j < n;j ++)
20         {
21             int temp = 0;
22             for(int i = 0;i < m;i ++)
23             {
24                 temp = max(temp,grid[i][j]);
25             }
26             res += temp;
27         }
28         return res;
29     }
30 };

 

883. 三维形体投影面积

原文:https://www.cnblogs.com/yuhong1103/p/12803827.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!