Javascript implementation of the approach
let maximum = Number . MIN_VALUE , x , ans = Number . MAX_VALUE ; let graph = new Array ( 100 ) ; for ( let i = 0 ; i < 100 ; i ++ ) { graph [ i ] = [ ] ; } let weight = [ ] ;