Why is this code not working for this Question?
Why is this code not working for this Question?
hello @cbcao263
how u will ensure that u are considering not more than n elements in ur sum.
for example->
n-> 3
array -> 1 2 3
try to run ur code over this test case.
I am not able to Understand, Can You Please explain it to me
see u have doubled the array that means now we have 2*n elements right?
but we can include at most n consecutive elements in our answer .
but kadane can report answer by including more than n elements which is wrong .
consider the case that i mentioned.
n-> 3
array -> 1 2 3
doubling the array -> 1 2 3 1 2 3
now if u apply kadane over this it will give 12 , but correct answer is 6.
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.