11. Container With Most Water
# Medium
Two pointers.
Left pointer and right pointer to make sliding window. Keep maximum area
in record, and move left or right pointer to ensure both of them are the longest vertical lines, compute the temporary area to be temp
.
Solution
Keep maxium area in record.
Move left or right pointer each time by finding the longest two lines.
简单来说,有两种可能性能找到最大值,第一种距离尽量最远的两个垂线,第二种高度尽量最高的两条垂线。
Time complexity = , space complexity =
Last updated