How will you trap rain water?

5

1 votes
Easy
Problem

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

Sample Input
2 0 2
Sample Output
2
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

enter image description here

Editor Image

?