{1,2,3,-10,8} the max sum is 6 but the sum will be 8.
Kadane's method what if an element is larger then the sum
@tanishchaurasia56 hey tanish the ans is 8 using kadane algo
and you can also understand with this
1 =1
1 2 =2
1 2 3 =6
1 2 3 -10=-4
1 2 3 -10 8=4
2 =2
2 3 =5
2 3 -10 =-5
2 3 -10 8=3
3=3
3 -10 =-7
3 -10 8=1
-10=-10
-10 8=2
8=8
so last subarray will have maximum value.
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.