Magicsheet logo

Projection Area of 3D Shapes

Easy
12.5%
Updated 8/1/2025

Asked by 1 Company

Projection Area of 3D Shapes

What is this problem about?

The Projection Area of 3D Shapes problem gives you a 2D grid of column heights (stacks of unit cubes). Find the total projection area on three planes: top (XY), front (XZ), and side (YZ). This easy coding problem tests 2D matrix column/row analysis with geometry. The array, matrix, math, and geometry interview pattern is demonstrated.

Why is this asked in interviews?

Google asks this to test 3D geometry reasoning through a 2D grid representation. The key insight: top projection = count of non-zero cells; front projection = max per column (sum of column-wise maxima); side projection = max per row (sum of row-wise maxima).

Algorithmic pattern used

Three independent projections. Top (XY plane): count cells where grid[i][j] > 0. Front (XZ plane): for each column j, add max(grid[i][j] for all i). Side (YZ plane): for each row i, add max(grid[i][j] for all j).

Example explanation

Grid=[[2,0,2],[1,1,1],[0,0,2]]. Top: non-zero cells: (0,0)=2,(0,2)=2,(1,0)=1,(1,1)=1,(1,2)=1,(2,2)=2. Count=6. Front (column maxima): col0→max(2,1,0)=2. col1→max(0,1,0)=1. col2→max(2,1,2)=2. Sum=5. Side (row maxima): row0→max(2,0,2)=2. row1→max(1,1,1)=1. row2→max(0,0,2)=2. Sum=5. Total = 6+5+5 = 16.

Common mistakes candidates make

  • Confusing which projection uses row max vs column max.
  • Forgetting to count only non-zero cells for the top projection.
  • Off-by-one in grid dimensions.
  • Not handling 0-height columns (0 contributes nothing to front/side projection).

Interview preparation tip

3D projection problems reduce 3D geometry to 2D array operations. Memorize: top=count(non-zero), front=sum(column-max), side=sum(row-max). Practice similar "shadow area" problems: "maximum area of projection," "overlapping shadows." 3D geometry appears in graphics programming and simulation interviews — understanding projections from different planes is the core skill.

Similar Questions