Q11. Container With Most Water
Last updated
Was this helpful?
Last updated
Was this helpful?
直达:
Givennnon-negative integers where each represents a point at coordinate . vertical lines are drawn such that the two endpoints of lineiis at and . 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 is at least 2.
从数组两端开始遍历,每次更改高度最小的那个下标。