美文网首页
maximum-depth-of-binary-tree

maximum-depth-of-binary-tree

作者: DaiMorph | 来源:发表于2019-05-31 00:15 被阅读0次
class Solution {
public:
    int maxDepth(TreeNode *root) {
        if(root==NULL)return 0;
        return max(maxDepth(root->left),maxDepth(root->right))+1;
    }
};

网友评论

      本文标题:maximum-depth-of-binary-tree

      本文链接:https://www.haomeiwen.com/subject/uxlitctx.html