← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given an integer array heights where heights[i] represents the height of the i-th bar. You may choose any two bars to form a container. Return the maximum amount of water a container can store.
Example 1:
Input: heights = [1,8,6,2,5,4,8,3,7] Output: 49 Explanation: The above vertical lines represent the bars. The maximum amount of water (blue section) we can have is 49.
Example 2:
Input: heights = [1,1] Output: 1
Example 3:
Input: heights = [4,3,2,1,4] Output: 16
Example 4:
Input: heights = [1,2,1] Output: 2
Constraints:
n == heights.length2 <= n <= 10^50 <= heights[i] <= 10^4Follow-up: Can you solve it using a two-pointer technique?