Find one with max profit
for ( int i = 0 ; i < L . size ( ) ; i ++ ) if ( findSum ( L . get ( i ) ) > findSum ( maxChain ) ) maxChain = L . get ( i ) ; for ( int i = 0 ; i < maxChain . size ( ) ; i ++ ) { System . out . printf ( "(%d, %d, %d)NEW_LINE", maxChain . get ( i ) . start , maxChain . get ( i ) . finish , maxChain . get ( i ) . profit ) ; } }