class Solution {
public:
int projectionArea(vector<vector<int>>& grid) {
int xy = 0;
for (int i = 0; i < grid.size(); i++) {
for (int j = 0; j < grid[0].size() ;j++ ) {
if (grid[i][j] > 0) xy ++;
}
}
int yz = 0;
for (int i = 0; i < grid[0].size(); i++) {
int myz = 0;
for (int j = 0; j < grid.size(); j++) {
myz = max(myz, grid[j][i]);
}
yz += myz;
}
int zx = 0;
for (int i =0 ; i < grid.size(); i++) {
int mzx = 0;
for (int j = 0; j < grid[0].size(); j++) {
mzx = max(mzx, grid[i][j]);
}
zx += mzx;
}
return xy + yz + zx;
}
};