---
# System prepended metadata

title: LC11 - Container With Most Water

---

# LC11 - Container With Most Water
# Two Pointers

```java=
class Solution {
    public int maxArea(int[] height) {
        // sanity check
        // ...
        
        int length = height.length;
        int left = 0, right = length - 1;
        int result = 0;
        while (left < right) {
            result = Math.max(
                result, 
                (right - left) * (height[left] < height[right] ? height[left++] : height[right--])
            );
        }
        return result;
    }
}
```