# [11\. Container With Most Water](https://leetcode.com/problems/container-with-most-water/) :::spoiler Solution ```cpp= class Solution { public: int maxArea(vector<int>& height) { int left = 0, right = height.size() - 1; int res = 0, curArea = 0; while(left < right) { curArea = min(height[left], height[right]) * (right - left); res = max(res, curArea); if(height[left] < height[right]) ++left; else --right; } return res; } }; ``` - T: $O(N)$ - S: $O(1)$ :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up