Dodomeki
Sign in

56. Container With Most Water

Medium

Each position in alturas represents a vertical line drawn at that coordinate. Choose two lines to form a container and return the maximum amount of water it can hold between them, without tilting the lines.

Example 1
Input: alturas = [1, 7, 3, 5, 2, 6]
Output: 20
Explanation: The lines with heights 7 and 6 are four units apart.
Example 2
Input: alturas = [4, 4]
Output: 4
Constraints
  • 2 <= alturas.length <= 10^5
  • 0 <= alturas[i] <= 10^4
ArraysTwo pointers
Caso 1
alturas =
[1,7,3,5,2,6]
Expected =
24
Caso 2
alturas =
[4,4]
Expected =
4

Run checks these 2 cases. Submit runs all 6, including hidden ones.