@@ -0,0 +1,1311 @@
+/***%0A * Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.%0A * Note: You may not slant the container.%0A */%0Apublic class Solution %7B%0A    // Solution 1: Brute force O(n%5E2) O(1)%0A    public int maxArea(int%5B%5D height) %7B%0A        int ret = 0;%0A        int n = height.length;%0A        int temp;%0A        for (int i = 0; i %3C n - 1; i++) %7B%0A            for (int j = i; j %3C n; j++) %7B%0A                temp = Math.min(height%5Bi%5D, height%5Bj%5D) * (j - i);%0A                ret = temp %3E ret? temp : ret;%0A            %7D%0A        %7D%0A        return ret;%0A    %7D%0A%0A    // Solution 2: O(n) O(1)%0A    // Move the smaller one until start and end meet.%0A    public int maxArea(int%5B%5D height) %7B%0A        int start = 0;%0A        int end = height.length - 1;%0A        int result = 0;%0A        int area;%0A        while (start %3C end) %7B%0A            area = Math.min(height%5Bstart%5D, height%5Bend%5D) * (end - start);%0A            result = area %3E  result ? area : result;%0A            if (height%5Bstart%5D %3C= height%5Bend%5D)%0A                start++;%0A            else%0A                end--;%0A        %7D%0A        return result;%0A    %7D%0A%7D%0A%0A

add ContainerWithMostWater.java