Driver code
public static void main ( String args [ ] ) { int n = 4 ; int adj [ ] [ ] = { { 5000 , 3000 } , { 6000 , 2000 } , { 8000 , 1000 } , { 9000 , 6000 } } ; for ( int i = 0 ; i < dp . length ; i ++ ) for ( int j = 0 ; j < dp . length ; j ++ ) dp [ i ] [ j ] = - 1 ; System . out . println ( find ( 1 , 1 , n , adj ) + adj [ 0 ] [ 1 ] ) ; } }