1 var maxArea = function(height) { 2 var max = 0, 3 l = 0, 4 r = height.length - 1; 5 6 while (l < r) { 7 var capacity = (r - l) * Math.min(height[l], height[r]); 8 max = capacity > max ? capacity : max; 9 if (height[l] < height[r]) { 10 l++; 11 } else { 12 r--; 13 } 14 } 15 16 return max; 17 };