111Minimum Depth of Binary Tree
来源:互联网 发布:linux重启网络服务失败 编辑:程序博客网 时间:2024/06/05 17:46
方法一:(深度优先搜索,记得单个结点深度为1,注意边界情况。)class Solution {public: int minDepth(TreeNode *root) { if(root==0) return 0; if(root->left==NULL&&root->right==NULL) return 1; int l=0x3f3f3f3f,r=0x3f3f3f3f; if(root->left!=NULL) l=1+minDepth(root->left); if(root->right!=NULL) r=1+minDepth(root->right); return min(l,r); }};
0 0
- LeetCode(111)Minimum Depth of Binary Tree
- LeetCode: Minimum Depth of Binary Tree [111]
- LeetCode 111 Minimum Depth of Binary Tree
- [leetcode 111] Minimum Depth of Binary Tree
- 111Minimum Depth of Binary Tree
- 111Minimum Depth of Binary Tree
- [LeetCode 111]Minimum Depth of Binary Tree
- leetCode #111 Minimum Depth of Binary Tree
- leetcode-111 Minimum Depth of Binary Tree
- leetcode 111 Minimum Depth of Binary Tree
- leetcode || 111、Minimum Depth of Binary Tree
- Leetcode[111]-Minimum Depth of Binary Tree
- leetcode[111]:Minimum Depth of Binary Tree
- LeetCode 111 Minimum Depth of Binary Tree
- [leetcode 111] Minimum Depth of Binary Tree
- leetcode-111-Minimum Depth of Binary Tree
- Leetcode #111 Minimum Depth of Binary Tree
- leetcode 111: Minimum Depth of Binary Tree
- html - div样式 margin:0 auto 在IE8浏览器不居中的解决办法
- 翻转句子中单词的顺序
- 基于HTML5 canvas圆形倒计时器jQuery插件
- 第一周项目三.1---时间增加一秒、分、时
- Android实现button一边圆角一边直角
- 111Minimum Depth of Binary Tree
- 文章标题
- java 泛型
- 简单阐述JAVA内存模型中工作内存"拷贝"的理解
- AFNetworking库使用
- vmware 虚拟机 centos配置固定IP
- hibernate.cfg.xml配置文件详解
- Vector、ArrayList和hashtable、hashmap的异同
- 如果以后要学习安卓,这些是很好的例子