Leetcode 剑指 Offer 55 - I. 二叉树的深度 思路 递归:树的高度就是左子树和右子树的高度最大者加一,非常简单。 代码 int maxDepth(TreeNode* root) { if(root==NULL) return 0; else{ int l=maxDepth(root->left); int r=maxDepth(root->right); return max(l,r)+1; }