Skip to main content
mediumBlind 75

Container With Most Water

Given array of heights, find max water container area Area = min(height[i], height[j]) * (j - i) Example: [1,8,6,2,5,4,8,3,7] => 49

You're looking for two lines that hold the most water between them. The brute force checks every pair, but interviewers want to see you discover the two-pointer insight: start wide, then shrink inward by moving the shorter line. It's a beautiful example of greedy reasoning that comes up in many optimization problems.

Arrays & HashingTwo PointersGreedy

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Container With Most Watermedium
2Part 2
3Part 3

Each locked part opens in the editor once the part before it passes.

Based onLeetCode