Skip to content

Commit

Permalink
添加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Sep 9, 2018
1 parent feac2ba commit fdac2e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lc892-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ def surfaceArea(self, grid):
:type grid: List[List[int]]
:rtype: int
"""

# 外面,包括凹下去的。
# 欣宜还是考虑复杂了,负的也没关系,用绝对值就行了。不需要两个方向都跑一次。
def helper(heights):
cur = 0
ret = 0
Expand All @@ -14,11 +17,14 @@ def helper(heights):
return ret

area = 0
# 每一行
for row in grid:
area += helper(row)

# 每一列
for col in zip(*grid):
area += helper(col)

# 上下底面
area += sum(2 for row in grid for h in row if h > 0)
return area

0 comments on commit fdac2e4

Please sign in to comment.