Wednesday, September 24, 2014

Container with Most Water

Problem

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
Note: You may not slant the container.

Idea

这个题和算矩阵面积那个不同,这个一旦有短板,则围城的面积一定小于没有短板的。
另外那个水槽的题则是求能呈水的总量

Solution


No comments:

Post a Comment