剑指 Offer 55 - I 二叉树的深度
概述
https://leetcode-cn.com/problems/er-cha-shu-de-shen-du-lcof/
https://leetcode.com/problems/maximum-depth-of-binary-tree/
递归法
class Solution {
public:
int maxDepth(TreeNode* root) {
if (!root) return 0;
return 1 + max(maxDepth(root->left), maxDepth(root->right));
}
};
Links: sword-offer-55-1