When currentsum is calculated, for cases where i = 0, shouldn’t csum[i-1] throw an out of bounds error?
Index error doubt
actualy sir starts loop from i=1
i=0 case is handled seperately outside the loop
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask
okay
this is wrong
it will show error or not depend on machine
if this memory is allocated to program then there will be no error otherwise segmentation fault will be shown
From what I understand, when an array of size n is initialized, only indices 0 to n-1 are available for use, so how is the program able to access -1 index which doesn’t exist without error? If -1 is available too, it should have garbage value, not 0, right? Please clarify.
yes you are right you can use only from 0 to n-1
but arr[-1] may exist depend on machine
arr[-1] means going one step backward
this may give error on your machine try to avoid these things they are uncertain
yes it may contain garbage then currentsum is some negative no hence maxsum will not change
Another doubt. How do I mark doubt as resolved? xD
