public int divide(int[] nums,int start, int end, int tmax){
if(start>end){
return Integer.MIN_VALUE;
}
int mid=start+(endstart)/2;
int lmax=divide(nums,start,mid1,tmax);
int rmax=divide(nums,mid+1,end,tmax);
tmax=Math.max(tmax,Math.max(lmax,rmax));
int sum=0,mlmax=0;
for (int i = mid1; i >=start; i) {// why goes from mid1 to start. why can't i go from the start to the mid1
// for (int i = start; i <=mid1; i++) {
sum+=nums[i];
mlmax=Math.max(mlmax,sum);
}
sum=0;
int mrmax=0;
for (int i = mid+1; i <=end; i++) {
sum+=nums[i];
mrmax=Math.max(mrmax,sum);
}
return Math.max(tmax,nums[mid]+mlmax+mrmax);
}
For divide and conquer, Why iterating over left part can't go from start to mid but go from mid1 to the start


@RyanZhu1024
In loop
"for (int i = mid1; i >=start; i)"
mlmax the max sum that starts with nums[mid1].
If goes from the start to the mid1, like
"for (int i = start; i <=mid1; i++)"
mlmax will be the max sum that starts with nums[start].