'''
给定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. JS(JavaScript)的初了解8(更新中···)

    1.函数都有返回值…… 而方法的本质也是函数,所以也有返回值. Document.getElementById() 返回的是获取的标签 getElementsByClassName()和getElem ...

  2. Tag

    C# ASP.NET SQL SERVER .Net Entity Framework JS Question Records Others

  3. 洛谷 P3376 【【模板】网络最大流】

    题目描述 如题,给出一个网络图,以及其源点和汇点,求出其网络最大流. 输入 第一行包含四个正整数N.M.S.T,分别表示点的个数.有向边的个数.源点序号.汇点序号. 接下来M行每行包含三个正整数ui. ...

  4. 用R语言做数据清理

    数据的清理 如同列夫托尔斯泰所说的那样:“幸福的家庭都是相似的,不幸的家庭各有各的不幸”,糟糕的恶心的数据各有各的糟糕之处,好的数据集都是相似的.一份好的,干净而整洁的数据至少包括以下几个要素: 1. ...

  5. CSS实现水平垂直居中的1010种方式

    转载自:CSS实现水平垂直居中的1010种方式 划重点,这是一道面试必考题,很多面试官都喜欢问这个问题,我就被问过好几次了 要实现上图的效果看似很简单,实则暗藏玄机,本文总结了一下CSS实现水平垂直居 ...

  6. h5视频播放

    h5视频播放 一直在写js原生的东西,感觉总是停滞不前,现在我们应该学一些h5新的特性,因为我们毕竟是从事前端的,下面我们一起来写一个视频播放吧 1,html <div class=" ...

  7. C#演示如何使用 XML 将源码编入文档

    工作闲暇时间,将做工程过程中常用的代码段记录起来,下面的代码是关于C#演示如何使用 XML 将编入文档的代码,希望对大伙有较大帮助. using System; public class SomeCl ...

  8. selenium 模拟拖动滚动条下拉

    senium做自动化测试的过程中,有的页面需要下拉滚动条才能全部加载完成,否则加载不出来就定位不到想要的元素. 参考链接:http://www.cnblogs.com/landhu/p/5761794 ...

  9. CSS清除浮动的一种简便的方法

    在使用的浮动的元素的父元素添加该CSS样式 .clear{ overflow: auto; }

  10. oracle drop 表后 恢复

    1.查看回收站中表 select object_name,original_name,partition_name,type,ts_name,createtime,droptime from recy ...