@@ -0,0 +1,644 @@
+class Solution %7B%0A    public int trap(int%5B%5D height) %7B%0A        if(height == null %7C%7C height.length %3C 2) return 0;%0A        Stack%3CInteger%3E stack = new Stack%3C%3E();%0A        int i = 0;%0A        int ret = 0;%0A        while(i %3C height.length) %7B%0A            %0A            while(!stack.isEmpty() && height%5Bstack.peek()%5D %3C height%5Bi%5D) %7B%0A                int cur = stack.pop();%0A                if(stack.isEmpty()) %7B%0A                    break;%0A                %7D%0A                ret += ((Math.min(height%5Bi%5D, height%5Bstack.peek()%5D) - height%5Bcur%5D) * (i-stack.peek() - 1));%0A            %7D%0A            stack.push(i);%0A            i++;%0A        %7D%0A        return ret;%0A    %7D%0A%7D%0A

Create lc42.java