'''
给定n个非负整数表示每个条的宽度为1的高程图,计算下雨后能够捕获多少水。
例如,
鉴于[0,1,0,2,1,0,1,3,2,1,2,1],返回6。
这个题要先算出盛满水后的高程图,减去前者就是雨水。
盛水多高取决于左右最高的两处低的一方。
'''
l1=[0,1,0,2,1,0,1,3,2,1,2,1]
w=[]
for i in range(len(l1)):
    w.append(min(max(l1[0:i+1]),max(l1[i:]))-l1[i])
print('收集雨水:',sum(w))

leetcode python 042收集雨水的更多相关文章

  1. [LeetCode] 407. Trapping Rain Water II 收集雨水 II

    Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevati ...

  2. [LeetCode] Trapping Rain Water 收集雨水

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  3. [LeetCode] 42. Trapping Rain Water 收集雨水

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  4. Leetcode Python Solution(continue update)

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

  5. Python零散收集:

    Python零散收集 转义字符 描述 \(在行尾时) 续行符 \\ 反斜杠符号 \’ 单引号 \” 双引号 \a 响铃 \b 退格(Backspace) \e 转义 \000 空 \n 换行 \v 纵 ...

  6. python信息收集之子域名

    python信息收集之子域名 主要是以下3种思路: 字典爆破 搜索引擎 第三方网站 0x00 背景知识 list Python内置的一种数据类型是列表:list是一种有序的集合. >>&g ...

  7. [转]Python 模块收集

    Python 模块收集 转自:http://kuanghy.github.io/2017/04/04/python-modules Python | Apr 4, 2017 | python 工具 a ...

  8. 【LeetCode】042 Trapping Rain Water

    题目: Given n non-negative integers representing an elevation map where the width of each bar is 1, co ...

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

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

随机推荐

  1. Arthas:线上问题排查工具

    安装 下载 java -jar arthas-boot.jar 查看版本: D:\Program Files\arthas $ java -jar arthas-boot.jar -version [ ...

  2. Windoes包管理工具(Scoop)

    Windoes包管理工具(Scoop) 对于习惯了apt-get,brew等工具的开发者来说,Windows下配置环境相对繁琐,这里推荐Win下的包管理工具Scoop. Win 包管理工具 Choco ...

  3. 获取占用fd最大的前20个进程

    for x in `ps -eF| awk '{ print $2 }'`;do echo `ls /proc/$x/fd 2> /dev/null | wc -l` $x `cat /proc ...

  4. 【ActiveReports 大数据分析报告】用数据分析的手段告诉你,复联4有多火爆?

    消失的人们会回来吗,奇异博士所说的1400万分之一可能性究竟是什么,还会有谁逝去? 4月24日零时,随着万众期待的<复仇者联盟4>(以下简称<复联4>)正式上映,一切谜底都将揭 ...

  5. 应对 Visual Stdio 编译时出现错误:常量中有换行符

    笔者最近用 Visual Stdio 时,发现一个问题,在某一次写完语言进行编绎运行时,出现了以下错误: C2001错误:变量中有换行符 C2413错误:语法错误 缺少")"(在& ...

  6. jQuery (含义 及 优缺点)

    jQuery是一套开源的JavaScript函数库,它主要是简化了对DOM的操作.兼容CSS3,兼容各大主流浏览器. 二.jQuery的特点: 1:轻量级的JS函数库 jQuery的核心js文件几十K ...

  7. 【Mac】【创建钥匙串】

    1 Mac在钥匙串创建系统证书失败 https://blog.csdn.net/lllkey/article/details/79423596 问题: 在Eclipse的Debug,使用gdb的时候, ...

  8. 2019金融科技风往哪儿吹?蚂蚁金服联合20余家金融机构预测新年热点:5G、区块链上榜

    2019年,金融科技的风向标在哪里?哪些板块成新宠,哪些科技成潮流? 1月4日,蚂蚁金服ATEC城市峰会在上海举行.大会上,蚂蚁金服与20余家金融机构一起预测了2019年金融科技的发展. “未来金融会 ...

  9. webgl学习

    学习网址: https://www.yiibai.com/webgl/webgl_shaders.html# 多重纹理 https://blog.csdn.net/Chase_freedom/arti ...

  10. stm32WB55xx 外设资源

    1.FLASH(闪存) 2.Radio System(无线系统:兼容BLE5.0与IEEE802.15.4标准,由2.4GHz射频前端.BLE和IEEE802.15.4物理层控制器组成,无线低功耗协议 ...