- 博客(2)
- 收藏
- 关注
原创 【LeetCode】递归判断平衡二叉树的代码
还是要多写啊……递归的思想太妙了int maxDepth(TreeNode*root){ if(root==NULL) return 0; else return max(1+maxDepth(root->left),1+maxDepth(root->right));} bool isBalanced(TreeNode* root) { if(root==NULL) return true; else
2020-11-20 13:32:38
123
原创 【LeetCode】一个简单的递归求二叉树最小深度的代码
一个简单的递归求二叉树最小深度的代码class Solution {public:int min(int x,int y){ return(x>y? y:x);} int minDepth(TreeNode* root) { if(root==NULL) return 0; if(root->left==NULL&&root->right==NULL){ return 1; }
2020-11-18 21:19:59
153
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人