MAXIMUM SUBARRAY SUM

I’d used kadane’s algorithm here , but 1 test case is not passing ,please check the code?

@CODER_JATIN, initialize your current_sum with 0 for every test case also initialize your max_sum with INT_MIN to handle the case when every element is negative

corrected code :-

Alright , that’s worked fine. thankyou bhaiya.

One more thing i want to ask you that, agar array mai saare numbers negative ho to kadane’s algorithm tab work nhi karega naa??

kadane ko work karne ke lia atleat ek element positive hona hi chahiye

hanji, agar saare elements negative hue to tab ans 0 aayega??

haan , kyunki curr_max jaise hi negetive hoga usse 0 kardete hai max_sum se compare karne se pehle

Hanji, alright bhaiya, thank you so much.