Problems178
Search for a command to run...
Try your own input
Change the array and replay the algorithm from step one.
Current step
Find two lines forming the largest container. Area = min(h[L], h[R]) × (R - L).
Two Pointers
1function maxArea(height) {//left: 0right: 8maxArea: 02 let left = 0, right = height.length - 1;3 let maxArea = 0;4 while (left < right) {5 const area = Math.min(height[left], height[right]) * (right - left);6 maxArea = Math.max(maxArea, area);7 if (height[left] < height[right]) {8 left++;9 } else {10 right--;11 }12 }13 return maxArea;14}