run time error
Max. subarray sum
Hi @apoorveesharma2308, you have not written the code according to given input format. Pls take input correctly and then process it. Rest, your Kadane’s algo is correct.
Also, you need not include the separate max function, since u can use inbuilt max function, and also when u are taking input of array, use kadane function for every test case there only, rather than passing the loop again, since it is actually producing wrong answer, as the output should be
10
15
for sample case, but your code is giving 15 and 20 as the output.