題目鏈接: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;
}
};