Given an array of integers where each element reprensents the height of the tower. The width of each tower is 1. It starts raining. How will you find the amount of water collected among towers?
- given array [1,0,2,0,1,0,0,0,5,0,2,0,0,0,10,0,8,0,5] amount of water collected is 46.
| |
| | |
| | |#|
| | |#|
| | |#|
| | | | after |#####|#|#|
| | | | raining |#####|#|#|
| | | | |#####|#|#|
| | | | | | |#####|#|###|#|#|
|_|_|___|_|___|_|_| |#|#|###|#|###|#|#|