why the left and right variables initialize with -1?? and how it’s finding the --elements-- of the maximum sum array
question:- https://online.codingblocks.com/app/player/189104/content/180082/296/lecture
video time:- 6:00
why the left and right variables initialize with -1?? and how it’s finding the --elements-- of the maximum sum array
question:- https://online.codingblocks.com/app/player/189104/content/180082/296/lecture
video time:- 6:00
hello @dasvishal60
left and right variables will hold starting and ending index of maximum sum subarray.
intially we dont know where the max sum subarray is thats why we initialsied it with -1 (-1 indicates that we havent found any max sum subarray till now , u can use any negative number).
look at time stamp 6 : 14 -> at line 33 and 34 , we are storing starting and ending index of max sum subarray in left and right.
now to determine all the elements of max sum subarray , all we need to is iterate from index left to index right and print value present at that index
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.