Help with the code

I’m not able to solve this problm.Please help with the code.Thank you

u did not consider the t test cases
line 24
image

using divide and conquer

oh i saw the code u submitted i thought u needed help with that code

1) Divide the given array in two halves
2) Return the maximum of following three
…. a) Maximum subarray sum in left half (Make a recursive call)
…. b) Maximum subarray sum in right half (Make a recursive call)
…. c) Maximum subarray sum such that the subarray crosses the midpoint

The lines 2.a and 2.b are simple recursive calls. How to find maximum subarray sum such that the subarray crosses the midpoint? We can easily find the crossing sum in linear time. The idea is simple, find the maximum sum starting from mid point and ending at some point on left of mid, then find the maximum sum starting from mid + 1 and ending with sum point on right of mid + 1. Finally, combine the two and return.

not by kadane’s algo

Chhavi…I’ve switched on the collaborate mode.please tell me where my code is going wrong

for 2.c) I’ve taken ss and se as some points, on the left and right of mid

@aryan,
You don’t need some points in left and right of mid, simple maintain 2 variables which contain the maximum consecutive prefix and suffix respectively.

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.