Given Edges
let Edges = [ [ 0 , 1 ] , [ 1 , 2 ] , [ 1 , 4 ] , [ 3 , 4 ] , [ 4 , 5 ] ] ; for ( let i = 0 ; i < edges . length ; i ++ ) edges [ i ] = [ ] ; maximumCost ( 1 , - 1 , N , M , arr , Edges ) ; document . write ( ans ) ;