摘要: 110. 平衡二叉树 注意概念 二叉树节点的深度:指从根节点到该节点的最长简单路径边的条数。 二叉树节点的高度:指从该节点到叶子节点的最长简单路径边的条数。 class Solution { public: int getHeight(TreeNode* root){ if(root==NULL)r 阅读全文
posted @ 2023-01-13 14:41 芝士可乐 阅读(11) 评论(0) 推荐(0)
摘要: 104. 二叉树的最大深度 class Solution { public: int maxDepth(TreeNode* root) { if(root==NULL)return 0; return 1+max(maxDepth(root->left),maxDepth(root->right)) 阅读全文
posted @ 2023-01-13 00:50 芝士可乐 阅读(26) 评论(0) 推荐(0)