题目如下:

题目的意思是求容器能装的最大的水量,当时我按梯形的面积来算,一直不对,后来才发现要按矩形的面积来算

Python代码如下:

    def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
right = len(height)-1
left = 0
maxWater = 0
while(left<right):
maxWater = max(maxWater,min(height[left],height[right])*(right-left))
if(height[left]<height[right]):
left+=1
else:
right-=1
return maxWater

LeetCode(11)Container With Most Water的更多相关文章

  1. LeetCode(11) 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

    Problem: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate ...

  3. LeetCode(11):盛最多水的容器

    Medium! 题目描述: 给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) .画 n 条垂直线,使得垂直线 i 的两个端点分别为 (i, ai) 和 (i, ...

  4. Leetcode(11)-盛最多水的容器

    给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) .画 n 条垂直线,使得垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0).找出其中的两条线,使得 ...

  5. KineticJS教程(11)

    KineticJS教程(11) 作者: ysm 11.对象的上下关系 11.1.层的上下关系 Kinetic的层是按照添加到舞台的次序,由下向上排列,上层遮盖下层的图形.每个层各自有一个ZIndex编 ...

  6. SpringBoot学习笔记(11):使用WebSocket构建交互式Web应用程序

    SpringBoot学习笔记(11):使用WebSocket构建交互式Web应用程序 快速开始 本指南将引导您完成创建“hello world”应用程序的过程,该应用程序在浏览器和服务器之间来回发送消 ...

  7. Leetcode(4)寻找两个有序数组的中位数

    Leetcode(4)寻找两个有序数组的中位数 [题目表述]: 给定两个大小为 m 和 n 的有序数组 nums1 和* nums2. 请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O( ...

  8. Leetcode(5)最长回文子串

    Leetcode(4)寻找两个有序数组的中位数 [题目表述]: 给定一个字符串 s,找到 s 中 最长 的回文子串.你可以假设 s 的最大长度为 1000.' 第一种方法:未完成:利用回文子串的特点 ...

  9. Leetcode(6)Z字形变换

    Leetcode(6)Z字形变换 [题目表述]: 将一个给定字符串根据给定的行数,以从上往下.从左到右进行 Z 字形排列. 比如输入字符串为 "LEETCODEISHIRING" ...

随机推荐

  1. siblings() next() nextAll() nextUntil() prev() prevAll() prevUntil() 在 DOM 树中水平遍历

    $(document).ready(function(){ $("h2").siblings(); });拿到h2标签的所有的同级元素什么标签都可以 $(document).rea ...

  2. vj线段树专题

    vj线段树专题题解 单点更新模板 void build(int x,int l,int r){//sum[x]控制l-r区域 if(l==r){Sum[x]=num[l];return ;} int ...

  3. javascript的带操作符的赋值运算

    看犀牛书发现的问题 下面两个表达式 表达式一 data[i++] *= 2; 表达式二 data[i++] = data[i++] * 2;   var data = [7,8,9]; var i = ...

  4. ansible --help 文档

    > ansible --help Usage: ansible <host-pattern> [options] Define and run a single task 'play ...

  5. 02022_System类的方法练习

    1.验证for循环打印数字1-9999所需要使用的时间(毫秒) public class Test { public static void main(String[] args) { long st ...

  6. --- Error: failed to execute '.\ARMCC\bin\ArmAsm'

    1.KEIL4在开发STM32程序时报: Error: failed to execute '.\ARMCC\bin\ArmAsm' 或是Error: failed to execute '.\ARM ...

  7. SSM知识巩固2

    数据回显 1.springmvc默认对pojo数据进行回显. pojo数据传入controller方法后,springmvc自动将pojo数据放到request域,key等于pojo类型(首字母小写) ...

  8. POJ 2189

    P是端点,牛在区域中啊... #include <iostream> #include <cstdio> #include <cstring> #include & ...

  9. JS冒泡和闭包案例分析

    背景: 今天逛网页发现了百度知道上一个有意思的JS问题,提问者的问题事实上蛮简单的,懂点前端开发技术的应该都能实现.提问者的要求:实现子菜单的弹出,菜单共同拥有三级.每级菜单显示时有500毫秒的延迟. ...

  10. mysql Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)

    [现象说明] C/S程序远程訪问正常,本地訪问报下面异常 MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to h ...