Tree: Height of a Binary Tree

  • + 0 comments
    int height(Node* root) {
        // Write your code here.
        if (!root) return -1;
        int left = height(root->left);
        int right = height(root->right);
        return max(left, right) + 1;
    }