LeetCode:Minimum Depth of Binary Tree
来源:互联网 发布:域名映射是什么意思 编辑:程序博客网 时间:2024/05/01 07:26
宽搜
class Solution {public: int minDepth(TreeNode *root) { // Start typing your C/C++ solution below // DO NOT write int main() function if(root == NULL) return 0; int level = 1; vector<TreeNode*>tree; tree.push_back(root); int begin = 0; int end = 1; while(begin<end) { TreeNode* node = tree[begin]; if(node->right==NULL&&node->left==NULL) return level; if(node->right) tree.push_back(node->right); if(node->left) tree.push_back(node->left); if(begin == end-1) { end = tree.size(); level++; } begin++; } }};
- LeetCode: Minimum Depth of Binary Tree
- [Leetcode] Minimum Depth of Binary Tree
- LeetCode : Minimum Depth of Binary Tree
- leetcode 31: Minimum Depth of Binary Tree
- [LeetCode] Minimum Depth of Binary Tree - BFS
- [LeetCode] Minimum Depth of Binary Tree - DFS
- 【leetcode】Minimum Depth of Binary Tree
- LeetCode:Minimum Depth of Binary Tree
- [LeetCode]Minimum Depth of Binary Tree
- [Leetcode]Minimum Depth of Binary Tree
- [leetcode]Minimum Depth of Binary Tree
- Leetcode: Minimum Depth of Binary Tree
- LeetCode-Minimum Depth of Binary Tree
- [leetcode] Minimum Depth of Binary Tree
- LeetCode - Minimum Depth of Binary Tree
- 【Leetcode】Minimum Depth of Binary Tree
- LeetCode | Minimum Depth of Binary Tree
- LeetCode - Minimum Depth of Binary Tree
- 客户端使用EJB
- Windows下搭建PHP开发环境
- 沟通的艺术之"迷你裙"式幻灯片
- 淘宝开放平台API
- 统计论坛在线人数
- LeetCode:Minimum Depth of Binary Tree
- sql1992.txt
- Exception loading sessions from persistent storage
- 使用C语言操作MySQL数据库 Codeblocks开发环境配置
- 组播双网卡收不到数据的问题
- 使用开源软件OpenIPMI来监控服务器温度
- 【php】随机验证码的生成
- icinga用NSCA监控远程Linux服务器
- 2013寒假计划