not getting approach on how to start this problem.
Rain water harvesting problem
Basic Insight:
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.
this is basic approach try to implement this and
also try to do some optimisations
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask
getting error for two testcases in sprial print problem.
i think you forgot to print END at end
please open a new doubt for this and mark this doubt as resolved
think i have resolved your doubt
so please mark this doubt as resolved
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.