i have done it using this way, how can we optimize this code
Rain Water Harvesting
An Efficient Solution is to the pre-compute highest bar on left and right of every bar in O(n) time. Then use these pre-computed values to find the amount of water in every array element…
Rest the approach will remain same only,…
Since you arent replying anything, I am marking this doubt as resolved… You can reopen it if u face any issues…