LeetCode 111. Minimum Depth of Binary Tree
来源:互联网 发布:如何破解软件试用期 编辑:程序博客网 时间:2024/05/16 14:18
解题思路:DFS遍历整棵树,取最小深度
class Solution {public: int minDepth(TreeNode* root) { if(root == NULL) return 0; if(root->left == NULL) return 1+minDepth(root->right); if(root->right == NULL) return 1+minDepth(root->left); return min(1+minDepth(root->left),1+minDepth(root->right)); }};
0 0
- 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
- 111. Minimum Depth of Binary Tree LeetCode
- 【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
- 111.[Leetcode]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
- Android移动支付踩过的坑,哪里有坑哪里填(返回-1)
- 微型投影仪a
- scrapy框架的使用心得
- PHP1
- <转>推荐系统中基于深度学习的混合协同过滤模型
- LeetCode 111. Minimum Depth of Binary Tree
- 12期 2月期刊自荐
- SDL2 教程(二) Hello SDL!
- mysql查询相关的函数调用
- linux(ubuntu)下FTP的使用
- mac JDK环境变量
- ExtJS学习笔记(十三) Ext Form checkboxgroup、radiogroup和其他字段 设置和获取数据
- 6、数码管控制实验
- Oracle高级查询--分组查询篇