Tree: Height of a Binary Tree

Sort by

recency

|

989 Discussions

|

  • + 0 comments

    I've consistently been getting "We couldn't process your submission" errors for a solution that passes all tests for several days in a row.

  • + 0 comments

    def height(root): if root is not None: left_height = height(root.left) right_height = height(root.right) return max(left_height, right_height) + 1 else: return -1

    py code

  • + 0 comments

    I'm sorry what sort of boilerplate code is this supposed to be in C#??? I even know the solution to this but I can't even run...

    static int getHeight(Node root) {
    	// write code here
    }
    

    Testing a dummy case like

     if(root.Left == null && root.Right == null) {
            return 0;
        }
        return 1;
    

    gives COMPILATION errors:

    Solution.cs(1,22): error CS0246: The type or namespace name 'Node' could not be found (are you missing a using directive or an assembly reference?)
    Solution.cs(1,12): warning CS8321: The local function 'getHeight' is declared but never used
    

    Isn't root supposed to be initialized and passed by wrapper code???

  • + 0 comments

    Hello Everyone, if you have the aim of retrieving your lost stolen crypto Message Watchdogs Guard Team on Whats App. plus15 4 0 7 1 7 2 6 8 5

  • + 0 comments

    Solution in Java:

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