@@ -0,0 +1,1455 @@
+package com.leetcode.arraryList_2;%0A%0Apublic class TrapWater %7B%0A%09/**%0A%09 * Given n non-negative integers representing an elevation map where the%0A%09 * width of each bar is 1, compute how much water it is able to trap after%0A%09 * raining. For example, Given %5B0,1,0,2,1,0,1,3,2,1,2,1%5D, return 6.%0A%09 * %0A%09 * @param args%0A%09 */%0A%09static private int calcuteWater(int%5B%5D testArray) %7B%0A%09%09int len = testArray.length;%0A%09%09int%5B%5D outPut = searchMax(testArray, 0, len);%0A%09%09int mMax = outPut%5B0%5D;%0A%09%09int mMaxPos = outPut%5B1%5D;%0A%09%09return 0;%0A%09%7D%0A%0A%09static private int getWater(int %5B%5DtestArray,int pos, int mMax) %7B%0A%09%09int len = testArray.length;%0A%09%09if (pos %3E mMax) %7B%0A           int thisMax=searchMax(testArray, pos, len)%5B0%5D;%0A           int thisPos=searchMax(testArray, pos, len)%5B1%5D;%0A           int thisWater=0;%0A           for(int i=pos+1;i%3CthisPos;i++)%7B%0A        %09   thisWater+=thisMax-testArray%5Bi%5D;%0A           %7D%0A           return thisWater+getWater(testArray, thisPos, mMax);%0A%09%09%7D%0A           else %7B%0A%09%09%09return 0;%0A%09%09%7D%0A%09%0A%09%7D%0A%0A%09static private int%5B%5D searchMax(int%5B%5D testArray, int low, int high) %7B%0A%09%09int max = Integer.MAX_VALUE;%0A%09%09int pos = -1;%0A%09%09for (int i = low; i %3C high; i++) %7B%0A%09%09%09if (max %3C testArray%5Bi%5D) %7B%0A%09%09%09%09max = testArray%5Bi%5D;%0A%09%09%09%09pos = i;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09int%5B%5D outPut = new int%5B2%5D;%0A%09%09outPut%5B0%5D = max;%0A%09%09outPut%5B1%5D = pos;%0A%09%09return outPut;%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09final int%5B%5D testArray = %7B 0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1 %7D;%0A%09%09System.out.println(calcuteWater(testArray));%0A%09%7D%0A%0A%7D%0A

add unComplete java