'''
给定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. 三.SQL语句

    一.mysqladmin客户端命令 1.查看MySQL存活状态 [root@db01 ~]# mysqladmin -uroot -p123 ping 2.查看MySQL状态信息 [root@db01 ...

  2. 关于matplotlib绘制直方图偏移的问题

    在使用pyplot绘制直方图的时候我发现了一个问题,在给函数.hist()传参的时候,如果传入的组数不是刚刚好(就是说这个组数如果是使用(最大值-最小值)/组距计算出来,而这个数字不是整除得来而是取整 ...

  3. vue-router使用 看着篇就够了

    官网地址:https://router.vuejs.org/zh/ 先来个自我介绍吧,我就是你们口中的路由,我的作用就是告诉你们怎么到达某地,比如你想去一个地方(前提是这个地方是已经存在的)我会查询我 ...

  4. 记 Swagger 2

    Maven坐标: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox- ...

  5. shell 获得后台进程返回值

    获得后台进程返回值我们用“&”把进程放入后台以后,如果需要了解进程的执行情况,可以使用wait函数.默认情况下wait会等待任意子进程结束但是不会返回子进程的返回值.而以子进程的pid作为参数 ...

  6. ZT: C#不建类直接Json解析与取值

    C#不建类直接Json解析与取值 2017年10月19日 15:58:22 圆圆娃哈哈 阅读数:701    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn. ...

  7. 前端开发需要掌握的SEO的知识点

    SEO 工作的目的 seo 的工作目的是为了让网站更利于让各大搜索引擎抓取和收录,增加产品的曝光率. SEO 注意事项 1. 网站 TDK 标签的设置.title,description,keywor ...

  8. java非阻塞NIO和阻塞IO

    1         非阻塞NIO和阻塞IO 1.1           定义 阻塞IO:线程被阻塞,去处理一个读取和写入,中间如果有等待时间,则线程被占用,也不能处理其他任务: 非阻塞IO(new I ...

  9. JS-NaN的数据类型

    NaN 的数据类型:not a number .是数字类型但是不是数字 例: var x = Number('abcd'); //结果是NaN alert( typeof (x) ); //结果是nu ...

  10. prometheus相关文章

    prometheus book https://yunlzheng.gitbook.io/prometheus-book/ 开发自己的分布式监控Prometheus Exporter时遇到的坑 htt ...