Complete the code to find the middle index of the array segment.
mid := (low + [1]) / 2
The middle index is calculated by adding low and high indices and dividing by 2.
Complete the code to return the base case when low equals high.
if low == high { return arr[[1]], low, high }
When low equals high, the subarray has one element at index low.
Fix the error in the recursive call to find the left maximum subarray.
leftSum, leftLow, leftHigh := findMaxSubarray(arr, low, [1])The left subarray ends at mid - 1 to avoid overlapping with the middle element.
Fill both blanks to find the maximum crossing subarray.
crossSum, crossLow, crossHigh := findMaxCrossingSubarray(arr, [1], mid, [2])
The crossing subarray spans from low to high crossing mid.
Fill all three blanks to return the maximum subarray among left, right, and crossing sums.
if leftSum >= rightSum && leftSum >= crossSum { return [1], [2], [3] } else if rightSum >= leftSum && rightSum >= crossSum { return rightSum, rightLow, rightHigh } else { return crossSum, crossLow, crossHigh }
Return the left subarray sum and its indices when it is the maximum.
