CodeOath
← All problems

Container With Most Water

Medium
arraystwo-pointers

Given an array height where height[i] is the height of a vertical line at position i, find two lines that together with the x-axis form a container holding the most water. Return the max area.

Example:

Input: height = [1,8,6,2,5,4,8,3,7]
Output: 49

Constraints:

  • 2 <= height.length <= 10^5
  • 0 <= height[i] <= 10^4