题目描述:
![](https://i-blog.csdnimg.cn/blog_migrate/aab60c01e7e5c3e3a377d563395d48e2.png)
class Solution:
def trap(self, height):
"""
:type height: List[int]
:rtype: int
"""
l, r, res, tmp = 0, len(height)-1, 0, 0
while l < r:
if height[l] < height[r]:
lower = height[l]
l += 1
else:
lower = height[r]
r -= 1
tmp = max(tmp, lower)
res += tmp - lower
return res