In this video we will see how to compute how much water a given 'n' non-negative integers representing an elevation map where the width of each bar is 1, is able to trap after raining.
Examples:
Input: arr[] = {2, 0, 2}
Output: 2
Explanation: Imagine there are 3 columns. Now there are 2 bars on the 1st and 3rd column each and none in the second. Therefore the amount of water trapped is 2 (in the middle column).
Check out the video to see how we implement this!!
Practice Problem: https://practice.geeksforgeeks.org/problems/trapping-rain-water-1587115621/1
Article: https://www.geeksforgeeks.org/trapping-rain-water/
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/