Jis subarray ki sum maximum hai uss subarray ko print kar rhe hai by taking two variables left,right= -1… -1 se initialised kyu kiye hai…Aur fir if(cs>maxsum){
maxsum=currsum;left=i;right=j)…is condition loop me phir left=i and right=j kyu kiya gaya hai…
Prbl with code explanation
hello @rishabhkumargupta97 here we are updating the left pointer and the right pointer .
in the initial stage you are just declaring the left and right with -1 there is no logic behind that .
and at the end where you are doing left =i and right=j only if we found any subarray with large subarray sum value then we will update the value of left and right .
we are updating this because we have to print the subarray as well whose sum is maximum .
and by updating the left and right pointer of the array we can print the subarray which is producing maximum subarray sum .
if you still have any doubt you can ask here .
Happy Learning !!
sir,one more thing…if i posted a doubt and just after doubt posted it shows that mark as resolved with green sign…so,how to reopen a doubt
once you will mark the doubt as resolved then the option will be changes to reopen the doubt .
you can try this now by doing so .
Happy Learning !!
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.