Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
分类:
移动开发 时间:
2016-01-30 09:36:18
阅读次数:
221
题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raini...
分类:
移动开发 时间:
2015-12-25 13:30:41
阅读次数:
144
class Solution(object): def trap(self,nums): leftmosthigh = [0 for i in range(len(nums))] leftmax=0 for i in range(len(nums))...
分类:
移动开发 时间:
2015-12-24 23:55:03
阅读次数:
1432
问题:给定 n 个元素的数组 a1,a2..an,他们对应坐标中的 n 条线,第 i 条线的两端分别为坐标 (i, 0) 和 (i, ai)。求两根线,这两个线和 x 轴形成的容器能装最多的水。 这是一道直方图相关的题目,同样是直方图的题目还有:Trapping Rain Water 和 Larg...
分类:
其他好文 时间:
2015-12-23 01:50:01
阅读次数:
205
42、Trapping Rain Water题目这道题目参考http://www.cnblogs.com/felixfang/p/3713197.html观察下就可以发现被水填满后的形状是先升后降的塔形,因此,先遍历一遍找到塔顶,然后分别从两边开始,往塔顶所在位置遍历,水位只会增高不会减小,且一直和...
分类:
其他好文 时间:
2015-12-17 15:43:28
阅读次数:
120
题目来源https://leetcode.com/problems/trapping-rain-water/Givennnon-negative integers representing an elevation map where the width of each bar is 1, comp...
分类:
移动开发 时间:
2015-12-13 17:06:18
阅读次数:
179
Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Fo...
分类:
移动开发 时间:
2015-12-08 22:02:27
阅读次数:
391
原题链接在这里:https://leetcode.com/problems/candy/与Trapping Rain Water相似。每个孩子能拿到多少糖取决于左右两边,和能储存多少水取决于Math.min(左侧挡板最大值, 右侧挡板最大值)一个道理。所以先用leftNum保存根据左侧邻居,该孩子能...
分类:
其他好文 时间:
2015-11-05 08:51:02
阅读次数:
157
题目来源: https://leetcode.com/problems/trapping-rain-water/题意分析: 输入一组数组,代表一个宽度为1的高度地图。问,这个地图在雨后可以收集多少水。例如,输入一个数组[0,1,0,2,1,0,1,3,2,1,2,1],返回的是6.如图所示:题目.....
分类:
移动开发 时间:
2015-11-03 22:31:34
阅读次数:
229
链接:https://leetcode.com/problems/trapping-rain-water/【描述】Givennnon-negative integers representing an elevation map where the width of each bar is 1, c...
分类:
移动开发 时间:
2015-10-08 09:05:56
阅读次数:
255