Driver Code
let n = 4 ; let adj = [ [ 5000 , 3000 ] , [ 6000 , 2000 ] , [ 8000 , 1000 ] , [ 9000 , 6000 ] ] ; for ( let i = 0 ; i < dp . length ; i ++ ) for ( let j = 0 ; j < dp . length ; j ++ ) dp [ i ] [ j ] = - 1 ; document . write ( find ( 1 , 1 , n , adj ) + adj [ 0 ] [ 1 ] ) ;