function to find the maximum sum that exists in a subarray
static 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 = Math . Max ( arr [ i ] , curr_max + arr [ i ] ) ; max_so_far = Math . Max ( max_so_far , curr_max ) ; } return max_so_far ; }