This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class DistanceBetweenTwoNodesWithUnbuiltTree { | |
/* | |
* Distance between two nodes is number of edges between the two nodes | |
*/ | |
public static int distanceBetweenTwoNodesofBstWithUnbuiltTree(int[] insertionOrder, int node1, int node2) { | |
if (insertionOrder == null || insertionOrder.length == 0) { | |
return -1; |