1. 程式人生 > >11 Container With Most Water (medium)

11 Container With Most Water (medium)

eth with ont 繪制 repr end lin con alt

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.

給定n個非負整數a1,a2,...,an,其中每個表示坐標(i,ai)處的點。 繪制n條垂直線,使得線i的兩個端點在(i,ai)和(i,0)處。 找到兩條線,它們與x軸一起形成一個容器,使得容器含有最多的水。

技術分享

11 Container With Most Water (medium)