Lenskart | OA-2019 | Rain Trapping problem

image
Write a program to find how much water can be stored/traped,where the width of each bar is 1 unit
Ex-
Input - 6 (number of bars)
3 0 0 2 0 4 ( height of bars)
Output - 10
image

Comments (1)