function to find the maximum sum that exists in a subarray
int maxSubArraySum ( int arr [ ] , int size ) { int max_so_far = arr [ 0 ] ; int curr_max = arr [ 0 ] ; for ( int i = 1 ; i < size ; i ++ ) { curr_max = max ( arr [ i ] , curr_max + arr [ i ] ) ; max_so_far = max ( max_so_far , curr_max ) ; } return max_so_far ; }