Adjacency list to store edges
let adj = new Array ( N ) ; let lvl = new Array ( N ) ; let dist1 = new Array ( N ) ; let dist2 = new Array ( N ) ; let end = 0 , end2 = 0 , maxi = 0 ; for ( let i = 0 ; i < N ; i ++ ) { lvl [ i ] = 0 ; dist1 [ i ] = - 1 ; dist2 [ i ] = - 1 ; }