leetcode:Container With Most Water 6行AC

来源:互联网 发布:企业怎样做网络推广 编辑:程序博客网 时间:2024/06/08 10:28
class Solution {public:    int maxArea(vector<int>& height) {        int start = 0, end = height.size() - 1;        int imax = INT_MIN;        while (end > start) {            int res = (end - start) * (height[end] < height[start] ? height[end --] : height[start ++]);            imax = max(imax, res);        }        return imax;    }};

0 0
原创粉丝点击