Simple C solution using recursive


  • 0
    int maxDepth(struct TreeNode* root) {
        int left, right;
        if (root == NULL) 
            return 0;
        else{
            left = maxDepth(root->left);
            right = maxDepth(root->right);
            return 1 + ((left>right)?left:right);
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.