[思路:]
- 寻找树的最大深度,深度优先;
int maxDepth(TreeNode* root) {
if (!root) return 0;
return max(maxDepth(root->left), maxDepth(root->right)) + 1;
}
[思路:]
int maxDepth(TreeNode* root) {
if (!root) return 0;
return max(maxDepth(root->left), maxDepth(root->right)) + 1;
}
本文标题:104. Maximum Depth of Binary Tre
本文链接:https://www.haomeiwen.com/subject/nhlufftx.html
网友评论