@@ -0,0 +1,747 @@
+package problems;%0A%0Apublic class TrapRainWater %7B%0A    public int trap(int%5B%5D A) %7B%0A        int len = A.length;%0A        if (len %3C= 2)%0A            return 0;%0A%0A        int%5B%5D left = new int%5Blen%5D;%0A        int%5B%5D right = new int%5Blen%5D;%0A        for (int i = 1; i %3C len; i++) %7B%0A            left%5Bi%5D = Math.max(left%5Bi - 1%5D, A%5Bi - 1%5D);%0A            right%5Blen - i - 1%5D = Math.max(right%5Blen - i%5D, A%5Blen - i%5D);%0A        %7D%0A%0A        int sum = 0;%0A        for (int i = 1; i %3C len - 1; i++) %7B%0A            sum += Math.max(0, Math.min(left%5Bi%5D, right%5Bi%5D) - A%5Bi%5D);%0A        %7D%0A        return sum;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        TrapRainWater trw = new TrapRainWater();%0A        int%5B%5D A = %7B 4, 3, 7, 2 %7D;%0A        System.out.println(trw.trap(A));%0A    %7D%0A%7D%0A

Add Trapping Rain Water