Minimum Depth of Binary Tree(求二叉树的最小深度)
来源:互联网 发布:王侯将相宁有种乎电影 编辑:程序博客网 时间:2024/05/29 07:38
class Solution {
public:
int run(TreeNode *root) {
if (root==NULL){
return 0;
}
int l = run(root->left);
int r = run(root->right);
if (l==0||r==0){
return 1+l+r; //当前节点要么有一个分支,要么是根节点
}
return 1 + min(l,r);
}
};
public:
int run(TreeNode *root) {
if (root==NULL){
return 0;
}
int l = run(root->left);
int r = run(root->right);
if (l==0||r==0){
return 1+l+r; //当前节点要么有一个分支,要么是根节点
}
return 1 + min(l,r);
}
};
1 0
- Minimum Depth of Binary Tree(求二叉树的最小深度)
- Minimum Depth of Binary Tree 二叉树的最小深度
- Minimum Depth of Binary Tree 二叉树的最小深度
- Minimum Depth of Binary Tree 二叉树的最小深度
- 求二叉树的最小深度 Minimum Depth of Binary Tree
- LeetCode Minimum Depth of Binary Tree 最小深度二叉树
- Minimum Depth of Binary Tree 二叉树最小深度
- Leetcode Minimum Depth of Binary Tree 二叉树最小深度
- lintcode minimum-depth-of-binary-tree 二叉树最小深度
- LeetCode:minimum-depth-of-binary-tree(二叉树最小深度)
- LeetCode OJ 之 Minimum Depth of Binary Tree(二叉树的最小深度)
- 155.Minimum Depth of Binary Tree-二叉树的最小深度(容易题)
- Minimum Depth of Binary Tree 求二叉树最小高度/深度@LeetCode
- Tree-----求树的最大深度和最小深度(104. Maximum Depth of Binary Tree 111. Minimum Depth of Binary Tree)
- Leetcode:111. Minimum Depth of Binary Tree(求Tree的最小的深度)
- Minimum Depth of Binary Tree -- 二叉树的最小深度 DFS 加剪枝
- [Java代码] [Leetcode] Maximum and Minimum Depth of Binary Tree 二叉树的最小最大深度
- 111. Minimum Depth of Binary Tree 二叉树的最小深度
- 棋盘问题
- codeforce contest 713 #371 Div1 C
- vector<vector<int>>
- 发送邮件
- node学习-assert测试
- Minimum Depth of Binary Tree(求二叉树的最小深度)
- MyEclipse-blue2014怎样破解?
- NSOperation与performSelectorOnMainThread
- 使用Git将项目push至github
- 总结-UIWebView的使用-加载网页、html文件、本地文件等
- mac安装mysql数据库后忘记密码
- VLC的ACtiveX插件使用方法
- 聊聊设计模式 — 模板方法模式
- NOIp2009 最优贸易