leetcode 110:平衡二叉树

直接选择用递归就可以了,因为需要求高度,所以需要求深度。 int maxDepth(TreeNode*root){ if(root==NULL)return 0; TreeNode*l=root->left; TreeNode*r=root->right; return 1+std::max(maxDepth(l),maxDepth(r)); } bool isB
相关文章
相关标签/搜索