给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 **示例 1:**  ``` 输入:height = [0,1,0,2,1,0,1,3,2,1,2,1] 输出:6 解释:上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 ``` **示例 2:** ``` 输入:height = [4,2,0,3,2,5] 输出:9 ``` **提示:** - n == height.length - 0 <= n <= 3 * 104 - 0 <= height[i] <= 105 [leetcode](https://leetcode-cn.com/problems/trapping-rain-water)
Activity
latte03 commentedon Oct 30, 2020
暴力解法
双指针
AnranS commentedon Nov 18, 2020
栈
Forever17s commentedon Feb 27, 2021
双指针,中间向两边扩展
lewisYe commentedon Apr 8, 2021
暴力
这个leetcode 上超时了 优化一下如下
JohnApache commentedon Apr 28, 2021
可能用的指针比较多,基本原理也是双指针,做了一个右边双指针为了补全左双指针无法覆盖到的位置,应该有优化的空间