Container with Most Water
Try to solve the Container with Most Water problem.
We'll cover the following
Statement
You’re given an integer array height
of length , and there are vertical lines drawn such that the two endpoints of the line are and (, height[i]
).
Find two lines from the input array that, together with the x-axis, form a container that holds as much water as possible. Return the maximum amount of water a container can store.
Note: You may not slant the container.
Constraints:
-
height.length
-
-
height[i]
Examples
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.