1. Given n non-negative integers a1, a2, ..., an. 2. Each represents a point at coordinate (i, ai). 3. 'n' vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). 4. Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. 5. (Not volume because we are working with 2D so amount of water is basically Area). Note : that you may not slant the container.
Input Format
1. Take 'n', size of Array 2. Take 'n' different element for Array
Output Format
1. Max water
Constraints
1. n == height.length 2. 2 <= n <= 105 3. 0 <= height[i] <= 104
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
9 1 8 6 2 5 4 8 3 7
Output
49