Problems / Container With Most Water
Medium

Container With Most Water

Medium 56 submissions 25 coins +100 XP
Array Greedy Two Pointers
Problem Description
`height[i]` is the height of a vertical wall at position `i`. Choose two walls that, together with the x-axis, hold the most water. Return that maximum area (`width × shorter wall`). **Example 1:** ``` Input: height = [1, 8, 6, 2, 5, 4, 8, 3, 7] Output: 49 ``` **Example 2:** ``` Input: height = [1, 1] Output: 1 ``` **Example 3:** ``` Input: height = [4, 3, 2, 1, 4] Output: 16 ```
Constraints
- `2 <= height.length <= 10^5` - `0 <= height[i] <= 10^4`

Need help?

Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.

Video Call Whiteboard Live Coding Screen Share