Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def surfaceArea(self, grid: List[List[int]]) -> int:
- n = len(grid)
- res = 0
- for i in range(n):
- rh = 0
- ch = 0
- for j in range(n):
- t = grid[i][j]
- res += 2 if t else 0
- res += abs(t - rh)
- rh = t
- t = grid[j][i]
- res += abs(t - ch)
- ch = t
- res += rh + ch
- return res
Advertisement
Add Comment
Please, Sign In to add comment