leetcode#104:Maximum Depth of Binary Tree

来源:互联网 发布:程小青 知乎 编辑:程序博客网 时间:2024/06/05 05:48
int maxDepth(TreeNode* root) {        if(root == NULL)                return 0;        int maxL = maxDepth(root->left);        int maxR = maxDepth(root->right);        return maxL > maxR ? maxL + 1 : maxR + 1;