算法7月-O(n) 解决算法问题 最大存水量的 问题 Leetcode11- Container With Most Water

Given n non-negative integers a1a2, ..., an , where each represents a point at coordinate (iai). n vertical lines are drawn such that the two endpoints of line i is at (iai) 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 and n is at least 2.

Input: [1,8,6,2,5,4,8,3,7]
Output: 49
算法7月-O(n) 解决算法问题 最大存水量的 问题 Leetcode11- Container With Most Water_第1张图片  Leetcode11- Container With Most Water

 

 

 

 

 

你可能感兴趣的:(算法,算法)