Back to exercises

Container With Most Water

Use left and right pointers, compute the current area, and always move the side with the smaller height because only that can improve the limiting wall.

Coding Exercises Medium O(n)

Container With Most Water

Use left and right pointers, compute the current area, and always move the side with the smaller height because only that can improve the limiting wall.

Find two lines that together hold the maximum area of water.