LeetCode 11 Container With Most Water - Why Naive Fails

The trap

Check every pair of lines (i,j)(i, j) and compute area as min(height[i], height[j]) × (j - i). Track the maximum.

With n=105n = 10^5, you have roughly 5×1095 \times 10^9 pairs. That's far too slow.

You need a way to skip pairs that can't be optimal. What property tells you a pair is definitely worse than another?