Container With Most Water

00:00
MediumArrayTwo PointersGreedy
AmazonGoogle

Given heights array, find two lines forming a container holding the most water. Return max area.

Examples

Input → [1,8,6,2,5,4,8,3,7]
Output → 49
Note: indices 1&8, width=7, min-height=7
Input → [1,1]
Output → 1
Input → [4,3,2,1,4]
Output → 16