int findMaxSum(vector<int>& nums, int low, int high){ if(low == high)return nums[low]; else{ int mid = (low+high)/2; int left = findMaxSum(nums, low, mid); int right = findMaxSum(nums, mid+1, high); int middle = findCrossSum(nums, low, mid, high); return max(max(left,right),middle); } }
int main() { int M[ROW][COL] = {{1, 2, -1, -4, -20}, {-8, -3, 4, 2, 1}, {3, 8, 10, 1, 3}, {-4, -1, 1, 7, -6} }; findMaxSum(M); return 0; }
int Solution::maxPathSum(TreeNode* A) { return findMaxSum(A); }
int maxSubArray(vector<int>& nums){ return findMaxSum(nums, 0, nums.size()-1); }