Skip to main content
Container With Most Water | AlgoCracked
AlgoCracked
ProblemsContainer With Most Water
Medium54.0% acceptance
Blind75ArrayTwo PointersGreedy

Container With Most Water

You are given an array height of n non-negative integers; each is a vertical line at that index. Pick two lines that, together with the x-axis, hold the most water . The amount of water between lines i and j is min(height[i], height[j]) × (j − i) . Return the maximum. Input format Input is a single array, e.g. [[1,8,6,2,5,4,8,3,7]] .

Loading workspace…