摘要: bool hasPathSum(TreeNode *root, int sum) { if (root == nullptr)return false; if (root->left == nullptr && root->right == nullptr) return sum == root-> 阅读全文
posted @ 2016-06-21 15:13 牧马人夏峥 阅读(180) 评论(0) 推荐(0)
摘要: 二叉树的最小深度 采用递归的方式求左右结点的高度,注意判断一个结点是否是叶子结点(左右子树都不存大)。 int minDepth(TreeNode *root) { return minDepth(root, false); } int minDepth(TreeNode *root, bool h 阅读全文
posted @ 2016-06-21 13:50 牧马人夏峥 阅读(79) 评论(0) 推荐(0)