标签:style blog class code java color
class Solution{ public: int maxArea(vector<int>& height) { int len = height.size(), low = 0, high = len -1 ; int maxArea = 0; while (low < high) { maxArea = max(maxArea, (high - low) * min(height[low], height[high])); if (height[low] < height[high]) { low++; } else { high--; } } return maxArea; } };
应该算是贪婪算法吧,直接从disscus里抄了,自己只能想出一个nlogn的,对贪婪没什么感觉,想不到
LeetCode Container With Most Water,布布扣,bubuko.com
LeetCode Container With Most Water
标签:style blog class code java color
原文地址:http://www.cnblogs.com/lailailai/p/3715508.html