#10 most askedVery commonMediumTwo pointers
Container With Most Water
New to Two pointers? Learn it from scratch firstTwo Pointers & Stacks โ
๐ข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.height[i] is the height of a vertical line at position i. Pick two lines that, together with the x-axis, hold the most water. Return that amount.
[1, 8, 6, 2, 5, 4, 8, 3, 7] โ 49 (lines at 1 and 8: width 7 ร height 7).
๐งช Practice
Write your solution, then press Run tests. Explain your approach out loud as you go.
def max_area(height):
pass
Output appears here. Press Run or Ctrl/โ + Enter.
Try it first. Struggling for a few minutes is how it sticks.