Use two pointers at both ends; the limiting height is the smaller side.
Compute area = min(height[l], height[r]) * (r-l). Move the pointer on the smaller height inward.
Moving the taller side cannot increase min-height, while it always decreases width; only moving the shorter side can possibly increase min-height.
Use two pointers at both ends; the limiting height is the smaller side.
Compute area = min(height[l], height[r]) * (r-l). Move the pointer on the smaller height inward.
Moving the taller side cannot increase min-height, while it always decreases width; only moving the shorter side can possibly increase min-height.