← 返回 amazon 的题目列表Water Bottle Problem
类型:online_judge
amazon
You have a tank filled with water, consisting of multiple bottles with varying heights. You need to determine the maximum water capacity the bottles can contain. The capacity refers to the maximum water volume that can be contained, calculated as the minimum height column's capacity in the tank. Write an algorithm to compute the maximum water capacity the bottles can contain. The input is an array of bottle heights, and the output is an integer representing the maximum capacity. Input scale: number of bottles n range from 1 to 10000. Provide an O(n) time complexity algorithm.
Example
Input
[1,8,6,2,5,4,8,3,7]