Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Container With Most Water
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given an array of heights representing vertical lines, find two lines that, together with the x-axis, form a container that holds the most water.
Sample Input:
[1,8,6,2,5,4,8,3,7]
Sample Output:
49
Hints
Hint 1
Use two pointers starting at both ends of the array
Hint 2
Calculate area as min(height[left], height[right]) * (right - left)
Hint 3
Move the pointer pointing to the shorter line inward
Code Editor
Reset
Run
Save
Loading...