@@ -1 +1,2132 @@
+//Importing necessary packages%0Aimport java.util.*;%0A%0A// A Binary Tree node%0Aclass Node%7B%0A%09int data;%0A%09Node left, right;%0A    %09Node(int item)%7B%0A       %09%09data = item;%0A        %09left = right = null;%0A    %09%7D%0A%7D%0A%0A// Sample input : 1                         %0A//                3%0A//                1 2 L 1 3 R      Tree%0A//                %09%09     1%0A//                %09%09    / %5C%0A//                %09%09   2   3%0A// Sample Output: 2                %0A%0Aclass HeightOfBinaryTree%7B%0A%09//one line height function%0A%09int height(Node root) %7B return (root != null) ? Math.max(height(root.left), height(root.right)) + 1 : 0;%7D%0A%0A%09// driver function to test the height function%0A    %09public static void main(String args%5B%5D)%7B%0A%09%09// Input the number of test cases you want to run%0A     %09%09Scanner sc = new Scanner(System.in);%0A        %09int t = sc.nextInt();%0A        %09while (t %3E 0)%7B%0A            %09%09HashMap%3CInteger, Node%3E hashMap = new HashMap%3CInteger, Node%3E ();%0A            %09%09int n = sc.nextInt();//number of nodes in the binary tree%0A            %09%09Node root=null;%0A            %09%09while (n %3E 1)%7B%0A                %09%09int parentValue = sc.nextInt();//parent node value%0A                %09%09int childValue = sc.nextInt();//new node value%0A                %09%09char leftOrRight = sc.next().charAt(0);//L or R to determine whether to insert the new node to the left(L) of right(R)%0A                %09%09Node parent = hashMap.get(parentValue);%0A                %09%09if (parent == null)%7B%0A                    %09%09%09parent = new Node(parentValue);%0A                    %09%09%09hashMap.put(parentValue, parent);%0A                    %09%09%09if (root == null)%0A                        %09%09%09root = parent;%0A                %09%09%7D%0A                %09%09Node child = new Node(childValue);%0A                %09%09if (leftOrRight == 'L')%0A                    %09%09%09parent.left = child;%0A                %09%09else%0A                    %09%09%09parent.right = child;%0A                %09%09%09hashMap.put(childValue, child);%0A                %09%09n--;%0A            %09%09%7D%0A%09%09%09//Create an object of the class%0A            %09%09HeightOfBinaryTree obj = new HeightOfBinaryTree();%0A%09%09%09//Test the one line function%0A%09%09%09System.out.println(obj.height(root));%0A         %09%09t--;%0A        %09%7D%09%0A    %09%7D%0A%7D%0A%0A
 %0A

Update HeightOfBinaryTree.java