int max( int x, int y) { return (y > x)? y : x; } int maxSubArray( const int * A, int n1) { int maxc = A[0], i; int curr_max = A[0]; for (i = 1; i < n1; i++) { curr_max = max(A[i], curr_max+A[i]); maxc = max(maxc, curr_max); } return maxc; } |
Where :=
A= Array
n1= Size of the Array
A= Array
n1= Size of the Array
No comments:
Post a Comment