> For the complete documentation index, see [llms.txt](https://ucan.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ucan.gitbook.io/notes/11.-container-with-most-water.md).

# 11. Container With Most Water

{% hint style="info" %}
Two pointer: start from the beginning and end of array, move forward (backward) on  the shorter side.
{% endhint %}

```java
class Solution {
    public int maxArea(int[] height) {
        int start = 0;
        int end = height.length-1;
        int maxArea = 0;
        
        while(start<end){
            maxArea = Math.max((end-start)*Math.min(height[start], height[end]), maxArea);
            if(height[start]<height[end]){
                start++;
            }else{
                end--;
            }
        }
        return maxArea;
        
    }
}
```
