return calculated distance
return level [ prevn1 ] + level [ prevn2 ] - 2 * level [ lca ] ; } static void preProcessing ( Node root , int N ) { for ( int i = 0 ; i < 4 * MAX ; i ++ ) { seg [ i ] = new Pair < > ( ) ; }