1class Solution {2public int projectionArea(int[][] grid) {3int totalArea = 0;45for (int[] row : grid) {6int max = row[0];7for (int c : row) {8if (max < c) {9max = c;10}11if (c != 0) {12totalArea += 1;13}14}15totalArea += max;16}1718for (int c = 0; c < grid[0].length; c++) {19int max = grid[0][c];20for (int row = 0; row < grid.length; row++) {21if (max < grid[row][c]) {2223max = grid[row][c];24}25}26totalArea += max;27}28return totalArea;29}30}