Close
Topic list
Buildings Projection
MEDIUM
15 mins
Matrices (2D Arrays)
Topics (Covered in this problem)
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Buildings Projection

Contributed by
Himanshu Tanwar
Medium
0/80
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

#### Your task is to find and return the total area of all three projections. See the example for more clarity.

##### Note:
`````` ‘GRID[i][j]’ = 0, if there is no building at cell (i, j).
``````
##### Example:
``````Consider the following 2*2 ‘GRID[][]’:
[1, 2]
[3, 4]

Its projection in XY, YZ, XZ plane is shown below -:
``````

``````Area covered in XY plane is 4, Area covered in YZ plane is 6, Area covered in ZX plane is 7, Thus the total area is 4 + 6 + 7 = 17.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
1
1
2
1 2
3 4
``````
##### Sample Output 1:
``````3
17
``````
##### Explanation of sample input 1:
``````In the first test case,  there is a 1*1 grid, and its only cell i.e cell (0, 0) has a building of height 1. Thus its projection in all three planes also takes area 1.

For the second test case, see the problem statement for an explanation.
``````
##### Sample Input 2:
``````2
3
0 0 0
0 0 0
0 0 0
3
1 1 1
1 0 1
1 1 1
``````
##### Sample Output 2:
``````0
14
``````
Auto
Console