Tree node structure used in the program
public class Node { public int data ; public Node left , right ; public Node ( int val ) { data = val ; left = right = null ; } } public class GFG { static int ans , lh , rh , f ; static Node k ; public static Node Root ;