Given an array of heights where each value represents a vertical line at that index, find two lines that together with the x-axis form a container holding the maximum amount of water, and return that maximum area.
height = [1,8,6,2,5,4,8,3,7]49height = [1,1]1Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Two indices move through a sorted (or sortable) structure — often from opposite ends or at different speeds — to avoid the nested loops a brute-force scan would need.
Read the full Two Pointers guide →
Original problem on LeetCode ↗