RAINWATER HARVESTING QUESTON

I’D DONE THE QUESTION THROUGH BRUTE FORCE APPROACH, BUT 3 TEST CASES ARE NOT PASSING, SO CAN YOU PLEASE CHECK MY CODE.

HAVE YOU CHECKED?? ?

@CODER_JATIN n is 1e6 brute force will not work it will give tle. you have to do this in o(n) app
refer this

Why brute force approach is not working, it is also given in the editorial.

@CODER_JATIN dont know why given in editorial but bruteforce is n square and n is 1e6 so n sq 1e12 which = 10000 seconds thats why dont work

ok , now i have do with the approach of 0(n) times

bhaiya, yaar ek baar thoda bta do ki kese problems ko approach karey first time mai hi…???

bro practice se hi ho paayega varna start mein pehli baar mein soch a mushkil hai brute force hi aata hai dinaag mein

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.