Leetcode 919 Solution
This article provides solution to leetcode question 919 (projection-area-of-3d-shapes)
Access this page by simply typing in "lcs 919" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/projection-area-of-3d-shapes
Solution
class Solution:
def projectionArea(self, grid: List[List[int]]) -> int:
n = len(grid)
im = collections.defaultdict(int)
jm = collections.defaultdict(int)
ans = 0
for i, j in itertools.product(range(n), range(n)):
if grid[i][j] == 0:
continue
im[i] = max(im[i], grid[i][j])
jm[j] = max(jm[j], grid[i][j])
ans += 1
return ans + sum(im.values()) + sum(jm.values())