```
class Solution(object):
def trap(self, height):
"""
:type height: List[int]
:rtype: int
"""
if not height :
return 0
count = 0
ind = height.index(max(height))
for i in range(ind):
if height[i] > height[i+1]:
count += height[i] - height[i+1]
height[i+1] = height[i]
for i in range(len(height) -1 , ind, -1):
if height[i] > height[i-1]:
count += height[i] - height[i-1]
height[i-1] = height[i]
return count
```