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.
Input: [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6
Before solving this problem, please take a look at โContainer with most water (https://www.prodevelopertutorial.com/find-the-container-with-most-water-explanation-with-diagram-and-solution-in-cpp-language/)โ problem. There I have explained in detail, how two pointers work.
Solution:
https://www.prodevelopertutorial.com/rain-water-trapping-in-c/