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++】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. Container With Most Water

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

  3. No.011 Container With Most Water

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

  4. LeetCode--No.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. Container With Most Water 、42. Trapping Rain Water 、238. Product of Array Except Self 、407. Trapping Rain Water II

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

  7. Leetcode 11. Container With Most Water(逼近法)

    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. [LeetCode][Python]Container With Most Water

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

随机推荐

  1. google android sdk下载hoosts

    203.208.46.146 www.google.com #这行是为了方便打开Android开发官网 现在好像不VPN也可以打开 74.125.113.121 developer.android.c ...

  2. AngularJS directive简述

    转自:http://segmentfault.com/q/1010000002400734 官方API:http://docs.angularjs.cn/api/ng/service/$compile ...

  3. ACM学习历程—HDU 5451 Best Solver(Fibonacci数列 && 快速幂)(2015沈阳网赛1002题)

    Problem Description The so-called best problem solver can easily solve this problem, with his/her ch ...

  4. 洛谷【P1104】生日(冒泡排序版)

    题目传送门:https://www.luogu.org/problemnew/show/P1104 题目很简单,我主要是来讲冒泡排序的. 所谓冒泡排序,流程如下: 每次确定一个\(rk\)(从\(n\ ...

  5. POJ1001(C++处理大数)

    Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 158025   Accepted: 38470 ...

  6. virtual judge(专题一 简单搜索 C)

    Description Farmer John has been informed of the location of a fugitive cow and wants to catch her i ...

  7. jQuery做出手风琴效果

    今天学到JQuery中的遍历-siblings,便手痒做了个手风琴的动态效果,有一点收获,分享给大家.mouseout的时候一定要记得opacity必须设置,不然li的opacity会保持mousem ...

  8. 修改initrd.img里ko文件的一个小tips

    在经历以下步骤解开initrd.img文件之后: 若file initrd.img 指示initrd.img为gzip文件,则2: mv initrd.img initrd.gz gunzip -d ...

  9. Python-requests取消SSL验证的警告InsecureRequestWarning解决办法

    使用requests模块请求一个证书无效的网站的话会直接报错 可以设置verify参数为False解决这个问题 # -*- coding:utf-8 -*- __author__ = "Mu ...

  10. ML 徒手系列 SVM

    在Lagrange乘子法中,介绍了如何构建及如何使用对偶函数,对目标问题进行求解. 这一章利用L乘子法对SVM进行推导. SVM 即支持向量机,是通过求解超平面进行分类的一种算法.所谓的支持向量,是在 ...