how to find maximum sub array in kadens algorithm…like right one as updated ms position and left one as starting one which is not updated to 0 position…explained subarray in every time complexity except at kadens algorithm

# Maximum sub array (kadens algorithm)

you want to ask that how we print subarray having max Sum?

this is how we print subarray also

```
int kadanesAlgo(int arr[],int n){
int curr_sum=0;
int max_sum=0;
int left=0;
int right=-1;
int curr_left;
for(int i=0;i<n;i++){
curr_sum+=arr[i];
if(curr_sum<0){
curr_sum=0;
curr_left=i+1;
}
if(curr_sum>max_sum){
max_sum=curr_sum;
left=curr_left;
right=i;
}
}
for(int i=left;i<=right;i++){
cout<<arr[i]<<" ";
}
cout<<endl;
return max_sum;
}
```

what does this means?