Storing the level of each node
level [ node ] = h ; if ( parent != -1 ) { minWeight [ node ] [ 0 ] = min ( weight [ node ] , weight [ parent ] ) ; maxWeight [ node ] [ 0 ] = max ( weight [ node ] , weight [ parent ] ) ; } for ( int i = 1 ; i < log ; i ++ ) { if ( lca [ node ] [ i - 1 ] != -1 ) {