题目描述:
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