题目链接:click~
/*题意:求二叉树的深度*/
class Solution {
public:
int maxDepth(TreeNode *root) {
if(root == NULL) return 0;
return max(maxDepth(root->left), maxDepth(root->right)) + 1;
}
};
题目链接:click~
/*题意:求二叉树的深度*/
class Solution {
public:
int maxDepth(TreeNode *root) {
if(root == NULL) return 0;
return max(maxDepth(root->left), maxDepth(root->right)) + 1;
}
};