package leetcode;

/**
 * https://leetcode.com/problems/surface-area-of-3d-shapes/
 */
public class Problem892 {
    public int surfaceArea(int[][] grid) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem892 prob = new Problem892();
        System.out.println(prob.surfaceArea(new int[][]{
            {1}
        })); // 6
        System.out.println(prob.surfaceArea(new int[][]{
            {2}
        })); // 10
        System.out.println(prob.surfaceArea(new int[][]{
            {3}
        })); // 14
        System.out.println(prob.surfaceArea(new int[][]{
            {1, 2}, {3, 4}
        })); // 10
        System.out.println(prob.surfaceArea(new int[][]{
            {1, 1}, {1, 1}
        })); // 16
        System.out.println(prob.surfaceArea(new int[][]{
            {1, 0}, {0, 2}
        })); // 10
        System.out.println(prob.surfaceArea(new int[][]{
            {1, 1, 1}, {1, 0, 1}, {1, 1, 1}
        })); // 10
        System.out.println(prob.surfaceArea(new int[][]{
            {2, 2, 2}, {2, 1, 2}, {2, 2, 2}
        })); // 10
    }
}

@@ -161,32 +161,538 @@
     
-// TODO%0A        return 0
+int result = 0;%0A        for (int i = 0; i %3C grid.length; i++) %7B%0A            for (int j = 0; j %3C grid%5Bi%5D.length; j++) %7B%0A                result += 4 * grid%5Bi%5D%5Bj%5D;%0A                if (j - 1 %3E= 0) %7B%0A                    int diff = Math.abs(grid%5Bi%5D%5Bj - 1%5D - grid%5Bi%5D%5Bj%5D);%0A                    result -= 2 * diff;%0A                %7D%0A                if (i - 1 %3E= 0) %7B%0A                    int diff = Math.abs(grid%5Bi - 1%5D%5Bj%5D - grid%5Bi%5D%5Bj%5D);%0A                    result -= 2 * diff;%0A                %7D%0A            %7D%0A        %7D%0A        return result
 ;%0A  
@@ -785,16 +785,18 @@
 m892();%0A
+//
         
@@ -836,32 +836,34 @@
 ea(new int%5B%5D%5B%5D%7B%0A
+//
             %7B1%7D%0A
@@ -862,16 +862,18 @@
     %7B1%7D%0A
+//
         
@@ -882,16 +882,18 @@
 ); // 6%0A
+//
         
@@ -933,32 +933,34 @@
 ea(new int%5B%5D%5B%5D%7B%0A
+//
             %7B2%7D%0A
@@ -959,16 +959,18 @@
     %7B2%7D%0A
+//
         
@@ -972,32 +972,34 @@
      %7D)); // 10%0A
+//
         System.o
@@ -1031,32 +1031,34 @@
 ea(new int%5B%5D%5B%5D%7B%0A
+//
             %7B3%7D%0A
@@ -1057,16 +1057,18 @@
     %7B3%7D%0A
+//
         
@@ -1170,35 +1170,37 @@
         %7D)); // 
-10%0A
+34%0A//
         System.o
@@ -1232,32 +1232,34 @@
 ea(new int%5B%5D%5B%5D%7B%0A
+//
             %7B1, 
@@ -1265,24 +1265,26 @@
  1%7D, %7B1, 1%7D%0A
+//
         %7D));
@@ -1290,16 +1290,18 @@
 ; // 16%0A
+//
         
@@ -1341,32 +1341,34 @@
 ea(new int%5B%5D%5B%5D%7B%0A
+//
             %7B1, 
@@ -1374,24 +1374,26 @@
  0%7D, %7B0, 2%7D%0A
+//
         %7D));
@@ -1389,34 +1389,36 @@
        %7D)); // 1
-0%0A
+6%0A//
         System.o
@@ -1450,32 +1450,34 @@
 ea(new int%5B%5D%5B%5D%7B%0A
+//
             %7B1, 
@@ -1504,16 +1504,18 @@
 , 1, 1%7D%0A
+//
         
@@ -1518,27 +1518,29 @@
     %7D)); // 
-10%0A
+32%0A//
         Syst
@@ -1576,32 +1576,34 @@
 ea(new int%5B%5D%5B%5D%7B%0A
+//
             %7B2, 
@@ -1630,16 +1630,18 @@
 , 2, 2%7D%0A
+//
         
@@ -1648,18 +1648,18 @@
 %7D)); // 
-10
+46
 %0A    %7D%0A%7D

Update problem 892