##
##给定n个非负整数a1,a2,...,an,其中每个表示坐标(i,ai)处的点。
##绘制n条垂直线,使得线i的两个端点位于(i,ai)和(i,0)。
##找到两条线,它们与x轴一起形成一个容器,这样容器就含有最多的水。
##对于容器(i,j)宽j-i,高min(l[i-1],l[j-1]),
def findcon(nl):
    large,l,r,num=0,0,0,len(nl)
    for i in range(num):
        for j in range(1,num-i):
            if min(nl[i],nl[i+j])*j>large:
                large,l,r=min(nl[i],nl[i+j])*j,i,i+j
                print(large,l,r)
    return '最大容器容积%s,左%s高%s右%s高%s。'%(large,l+1,nl[l],r+1,nl[r])
print(findcon([6,8,1,12,9,13,6,7,9]))

leetcode python 011的更多相关文章

  1. Leetcode Python Solution(continue update)

    leetcode python solution 1. two sum (easy) Given an array of integers, return indices of the two num ...

  2. LeetCode python实现题解(持续更新)

    目录 LeetCode Python实现算法简介 0001 两数之和 0002 两数相加 0003 无重复字符的最长子串 0004 寻找两个有序数组的中位数 0005 最长回文子串 0006 Z字型变 ...

  3. [LeetCode][Python]Container With Most Water

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

  4. LeetCode Python 位操作 1

    Python 位操作: 按位与 &, 按位或 | 体会不到 按位异或 ^ num ^ num = 0 左移 << num << 1 == num * 2**1 右移 & ...

  5. 【leetcode❤python】Sum Of Two Number

    #-*- coding: UTF-8 -*- #既然不能使用加法和减法,那么就用位操作.下面以计算5+4的例子说明如何用位操作实现加法:#1. 用二进制表示两个加数,a=5=0101,b=4=0100 ...

  6. [Leetcode][Python]56: Merge Intervals

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 56: Merge Intervalshttps://oj.leetcode. ...

  7. [Leetcode][Python]55: Jump Game

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 55: Jump Gamehttps://leetcode.com/probl ...

  8. [Leetcode][Python]54: Spiral Matrix

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 54: Spiral Matrixhttps://leetcode.com/p ...

  9. [Leetcode][Python]53: Maximum Subarray

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 53: Maximum Subarrayhttps://leetcode.co ...

随机推荐

  1. Oracle sqlplus的输出表的排版,数据表发生折行问题

    当查寻数据表的时候,会发生折行的问题 这时,我们可以用下面的语句 设置每行显示的记录长度:set    linesize    300;    --->  每行显示300个字符. 设置每页显示的 ...

  2. https://scrapingclub.com/exercise/detail_sign/

    def parse(self, response): # pattern1 = re.compile('token=(.*?);') # token = pattern1.findall(respon ...

  3. 快速搭建Vue项目

    快速搭建Vue项目 第一次安装vue项目Vue推荐开发环境Node.js 6.2.0.npm 3.8.9.webpack 1.13.vue-cli 2.5.1.webstrom2016 安装环境: 安 ...

  4. jenkins git can't work ERROR: Timeout after 10 minutes ERROR: Error fetching remote repo 'origin'

    Started by user Allen Running as Allen Building remotely on MISTestSrv2 (MIS) in workspace C:\jenkin ...

  5. 20190404用户及用户组管理(week1_day4)

    useradd userdel usermod groupadd groupdel 用户管理 为什么需要有用户? 1. linux是一个多用户系统 2. 权限管理(权限最小化) 用户:存在的目录是为了 ...

  6. aliplayer 视频播放报错

    问题总结: 1.引用 阿里库时href和src 文件路径不加http <link rel="stylesheet" href="//g.alicdn.com/de/ ...

  7. 【双目备课】OpenCV例程_stereo_calib.cpp解析

    stereo_calib是OpenCV官方代码中提供的最正统的双目demo,无论数据集还是代码都有很好实现. 一.代码效果: 相关的内容包括28张图片,1个xml和stereo_calib.cpp的代 ...

  8. 微信小程序wepy开发循环wx:for需要注意

    微信小程序wepy开发循环wx:for需要注意 item index值必须在wx:for之后使用 <view wx:for="{{tablist}}" class=" ...

  9. 如何插入谷歌地图并获取javascript api 秘钥--Google Maps API error: MissingKeyMapError

    参考:https://blog.csdn.net/klsstt/article/details/51744866 Google Maps API error: MissingKeyMapError h ...

  10. [原]jsbsim 自动驾驶c310ap文件改写

    <?xml version="1.0"?> <!-- Author: 南水之源 Date: 1 January 2019 Function: A-320 auto ...