Tree: Height of a Binary Tree

  • + 0 comments

    Java 8

    public static int height(Node root) {
            if(root==null){
            return -1;
            }
    
            int left = height(root.left);
            int right = height(root.right);
    
            return Math.max(left, right)+1;
    }