package leetcode;

/**
 * https://leetcode.com/problems/container-with-most-water/
 */
public class Problem11 {
    public int maxArea(int[] height) {
        int max = 0;
        int i = 0;
        int j = height.length - 1;
        while (i < j) {
            int area = Math.min(height[i], height[j]) * (j - i);
            if (height[i] < height[j]) {
                i++;
            } else {
                j--;
            }
            max = Math.max(max, area);
        }
        return max;
    }
}

@@ -156,19 +156,22 @@
     int 
-max
+answer
  = 0;%0A  
@@ -180,17 +180,20 @@
     int 
-i
+left
  = 0;%0A  
@@ -202,17 +202,21 @@
     int 
-j
+right
  = heigh
@@ -248,13 +248,20 @@
 le (
-i %3C j
+left %3C right
 ) %7B%0A
@@ -299,17 +299,20 @@
 (height%5B
-i
+left
 %5D, heigh
@@ -317,20 +317,76 @@
 ght%5B
-j
+right
 %5D) * (
-j - i
+right - left);%0A            answer = Math.max(answer, area
 );%0A 
@@ -407,17 +407,20 @@
 (height%5B
-i
+left
 %5D %3C heig
@@ -422,17 +422,21 @@
  height%5B
-j
+right
 %5D) %7B%0A   
@@ -448,17 +448,20 @@
         
-i
+left
 ++;%0A    
@@ -497,9 +497,13 @@
     
-j
+right
 --;%0A
@@ -520,47 +520,8 @@
   %7D%0A
-            max = Math.max(max, area);%0A
     
@@ -541,19 +541,22 @@
  return 
-max
+answer
 ;%0A    %7D%0A

Update problem 11