[Leetcode]011. Container With Most Water

时间:2021-08-13 22:33:36
public class Solution {
public int maxArea(int[] height) {
int left = 0, right = height.length - 1;
int maxArea = 0; while (left < right) {
maxArea = Math.max(maxArea, Math.min(height[left], height[right]) * (right - left));
if (height[left] < height[right])
left++;
else
right--;
} return maxArea;
} }

[Leetcode]011. Container With Most Water的更多相关文章

  1. 【JAVA、C&plus;&plus;】LeetCode 011 Container With Most Water

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

  2. 如何装最多的水? — leetcode 11&period; Container With Most Water

    炎炎夏日,还是呆在空调房里切切题吧. Container With Most Water,题意其实有点噱头,简化下就是,给一个数组,恩,就叫 height 吧,从中任选两项 i 和 j(i <= ...

  3. No&period;011 Container With Most Water

    11. Container With Most Water Total Accepted: 86363 Total Submissions: 244589 Difficulty: Medium Giv ...

  4. LeetCode--No&period;011 Container With Most Water

    11. Container With Most Water Total Accepted: 86363 Total Submissions: 244589 Difficulty: Medium Giv ...

  5. LeetCode OJ Container With Most Water 容器的最大装水量

    题意:在坐标轴的x轴上的0,1,2,3,4....n处有n+1块木板,长度不一,任两块加上x轴即可构成一个容器,其装水面积为两板的间距与较短板长之积,以vector容器给出一系列值,分别代表在0,1, ...

  6. leetcode 11&period; Container With Most Water 、42&period; Trapping Rain Water 、238&period; Product of Array Except Self 、407&period; Trapping Rain Water II

    11. Container With Most Water https://www.cnblogs.com/grandyang/p/4455109.html 用双指针向中间滑动,较小的高度就作为当前情 ...

  7. Leetcode 11&period; Container With Most Water&lpar;逼近法&rpar;

    11. Container With Most Water Medium Given n non-negative integers a1, a2, ..., an , where each repr ...

  8. 【LeetCode】011 Container With Most Water

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

  9. &lbrack;LeetCode&rsqb;&lbrack;Python&rsqb;Container With Most Water

    # -*- coding: utf8 -*-'''https://oj.leetcode.com/problems/container-with-most-water/ Given n non-neg ...

随机推荐

  1. SQLAlchemy query with OR&sol;AND&sol;like common filters

    http://www.leeladharan.com/sqlalchemy-query-with-or-and-like-common-filters Some of the most common ...

  2. hdu 4281&lpar;MTSP&rpar;

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4281 题意:给出N个点,第一个点是裁判,其他N-1个点需要裁判过去回答问题,每个点需要的时间不一样,而 ...

  3. LocalBroadcastManager 使用小解

    最近在开发平板项目,完全是fragmentactivity+fragment的结构.看起来似乎简单,但是和以前不同的是,业务逻辑非常复杂,多处的非常规跳转,fragment之间的数据交换,一处更新多处 ...

  4. 217&period; Contains Duplicate

    题目: Given an array of integers, find if the array contains any duplicates. Your function should retu ...

  5. rownum

    rownum是一个伪列,oracle数据库会对查找到的数据 从1 开始递增指定每行的rownum值, 当查询条件里有 rownum时(比如 where rownum>2),数据库会依次从数据集里 ...

  6. openwrt下加载snmp模块

    加snmp模块到openwrt中去 1.下载snmp的解压包文件 net-snmp-5.4.2.1.tar.gz 下载地址为:http://www.net-snmp.org/download.html ...

  7. iframe登录超时跳转登录页面

    1.可以在登录页面加jQuery验证 $(function () { //判断一下当前是不是做顶层,如果不是,则做一下顶层页面重定向 if (window != top) { top.location ...

  8. php实现最简单的MVC框架实例教程

    本文以一个实例的形式讲述了PHP实现MVC框架的过程,比较浅显易懂.现分享给大家供大家参考之用.具体分析如下: 首先,在学习一个框架之前,基本上我们都需要知道什么是mvc,即model-view-co ...

  9. ASP&period;NET MVC 自定义处理JSON ActionResult类

    1.统一JSON格式处理方式,同时指定ContentType类型,解决低版本浏览器获取json时ContentType为application/json提示下载的问题. public abstract ...

  10. C&plus;&plus; pbds 库平衡树(tree)

    头文件 #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //或者直接 ...