class Solution {
public:
    int maxArea(vector<int>& height) 
    {
        int l=0,r=height.size()-1;
        int area=0;
        while(l<r)
        {
            area=max(area,min(height[l],height[r])*((r-l)));
            if(height[l]<height[r])
                l++;
            else
                r--;
        }
        return area;
    }
};

Container With Most Water(C++)相关推荐

  1. 【贪心+双指针】LeetCode 11. Container With Most Water

    LeetCode 11. Container With Most Water Solution1: 参考网址:http://www.cnblogs.com/grandyang/p/4455109.ht ...

  2. Container with most water(盛水最多的容器)

    Container with most water(盛水最多的容器) 简单的证明 如图 题目: 给定 n 个非负整数 a1,a2,-,an,每个数代表坐标中的一个点 (i, ai) .在坐标内画 n ...

  3. leetcode -eleven:Container With Most Water

    2019独角兽企业重金招聘Python工程师标准>>> Given n non-negative integers a1, a2, ..., an, where each repre ...

  4. C#LeetCode刷题之#11-盛最多水的容器(Container With Most Water)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3615 访问. 给定 n 个非负整数 a1,a2,...,an,每 ...

  5. 【LeetCode】11. Container With Most Water 解题小结

    题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...

  6. LeetCode 11.Container With Most Water

    题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...

  7. LeetCode 11 Container With Most Water

    问题:给出一个数组nums,要求选择2个,使得容器中包含的水最多. 思路:假设选取x,y,其中x<y,则包含的水为min(x,y)*(index(y) - index(x)).此时应该选择在最小 ...

  8. leetcode - Container With Most Water

    题目链接:http://oj.leetcode.com/problems/container-with-most-water/ 第一个解法是用两个数组双向记录.方法的时间复杂度是O(n+max).这里 ...

  9. LeetCode11:Container With Most Water

    public int MaxArea(int[] height) {int start=0;int end=height.Length-1;int max=0;while(start<end){ ...

  10. [leetcode] Container With Most Water

    思路:最大面积等于两条垂直线中较小的一条乘以与x轴相交的长度,可以使用Two Pointers,一个从数组头开始(记为i),一个从数组尾部开始(记为j),当i < j时,一直循环找最大面积,如果 ...

最新文章

  1. win10 c盘清理_win10 C盘爆红怎么清理?
  2. OpenCASCADE:Foundation Classes之数学原语和算法
  3. hadoop中两种上传文件方式
  4. 论文浅尝 | 面向视觉常识推理的层次语义增强方向图网络
  5. python的workbook_python openpyxl 操作 excel
  6. Java™ 教程(原子变量)
  7. [ZT]ASP.NET中如何防范SQL注入式攻击
  8. 设计模式(六)原型模式
  9. 数据挖掘原理与实践学习(3)
  10. 高端游戏计算机配置单,全球最顶级的游戏电脑配置 高端游戏电脑装机推荐
  11. 0xl c语言中003是整形常量,整型常量
  12. 五,FreeRTOS之——相对延时与绝对延时
  13. 数据脱敏:保障数据安全的脱敏方案
  14. 6S大气校正模型源码
  15. Ubuntu桌面右键不管用解决办法
  16. DateFormat 线程安全
  17. SpringBoot整合Redis配置MyBatis二级缓存
  18. ESP8266+micropython+HCSR04 超声波测距传感器
  19. 【锐捷无线】AC热备配置
  20. 网页设计之栅格系统及应用

热门文章

  1. Three.js中的矩阵
  2. 堆排序算法(C#实现)
  3. hibernate中实体类对象的四种状态
  4. 菜鸟学Linux 第048篇笔记 配置slave server
  5. Linux 小知识翻译 - 目录 (完结)
  6. 国内趋于概念化的 “数据分析”在硅谷是怎样真正落地的?
  7. 设置vim默认显示行号
  8. 电信运营商推出1号2卡的应用设计
  9. 【COCOS2DX-LUA 脚本开发之十二】Hybrid模式-利用AssetsManager实现在线更新脚本文件lua、js、图片等资源(免去平台审核周期)...
  10. wordpress配置HTTPS遇到问题解决方案