In this problem of Rain water harvesting, I am not getting correct as per the given code.
If in line 14, we replace
" int mode = ar1[n-1]; "
with
" int mode = ar1[n-2]; "
I get correct output.
But first one should also be correct because ar1[n-1] will be the last element in the sorted array.
code link :
Not correct output
I am not getting all test cases passed eventhough. Please rectify the mistakes. Thank you!
@sanjit_15 you are just checking the bars between left maximum and right maximum but you have to check for all the bars. if some bar is outside between these two maximum can too store water depending on other bars.so come up with a technique to check water level for all bars.
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.