Step 2 of the pseudocode
for ( var i = level - 1 ; i >= 0 ; i -- ) if ( parent [ u ] [ i ] != parent [ v ] [ i ] ) { u = parent [ u ] [ i ] ; v = parent [ v ] [ i ] ; } return parent [ u ] [ 0 ] ; } function addEdge ( u , v ) { tree [ u ] . push ( v ) ; tree [ v ] . push ( u ) ; } function memset ( value ) { for ( var i = 0 ; i < MAXN ; i ++ ) { for ( var j = 0 ; j < level ; j ++ ) { parent [ i ] [ j ] = - 1 ; } } }