# Trapping Rain Water

Problem Link: <https://leetcode.com/problems/trapping-rain-water/>

```python
class Solution:
    def trap(self, height: List[int]) -> int:
        
        gtl=[]
        gtr=[]
        
        n=len(height)
        
        gtl.append(height[0])
        maxx=height[0]
        for i in range(1,n):
            maxx=max(maxx,height[i])
            gtl.append(maxx)
        
        gtr.append(height[n-1])
        maxx=height[n-1]
        for i in range(n-2,-1,-1):
            maxx=max(maxx,height[i])
            gtr.append(maxx)
        gtr=gtr[::-1]
        
        ans=0
        for i in range(n):
            ans=ans+min(gtl[i],gtr[i])-height[i]
        
        return ans
```
