Rain water harvesting

please give me code of that que so i can understand that question

An element of the array can store water if there are higher bars on left and right.

The amount of water to be stored in every element can be found out by finding the heights of bars on the left and right sides.

The idea is to compute the amount of water that can be stored in every element of the array.

Approach: The idea is to traverse every array element and find the highest bars on left and right sides. Take the smaller of two heights. The difference between the smaller height and height of the current element is the amount of water that can be stored in this array element.

now try to implement this approach
if you find difficulty in implementing the above approach feel free to ask