the output of the given test case should be 7 as the first elevation has height 0 and the water can also be collected there till height 2.
Rainwater trapping answer
@ppsingh12 I am guessing that u are talking about this test case
10
0 2 1 3 0 1 2 1 2 1
a) when will water collect at index i?
water will collect at index i only when there exist some elevation higher then elevation of index i to its left as well as to its right.
now coming to your doubt.
if u see index 0 then u will find that there is not any elevation to its left and thus no water will be collected over index 0 elevation
i hope you find this helpful.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
refer this