leetcode-1-Minimum Depth of Binary Tree
来源:互联网 发布:java画流程 编辑:程序博客网 时间:2024/06/03 06:58
知识点:树
题目描述:
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
思路1:递归解法
class Solution {
public:
int run(TreeNode *root) {
if (root==NULL)
return 0;
int n_left = run(root->left);
int n_right = run(root->right);
if (n_left==0||n_right==0)
return 1+n_left+n_right;
return n_left
阅读全文
0 0
- leetcode-1-Minimum Depth of Binary Tree
- 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
- servlet
- vs2013 调试libevent 源码
- 点击按钮桌面全屏功能
- win7环境下L2TP客户端找不到证书故障(766)解决
- hdu dp60题
- leetcode-1-Minimum Depth of Binary Tree
- 叉积
- webpack-sass-postcss-loader-单个css文件
- 我对Java Serializable(序列化)的理解和总结
- js 遇到的标签
- Luogu P1969 [NOIp提高组2013]积木大赛
- 2017年双十一大促临近,如何打造爆款?
- Android 源码解析-AsyncTask
- BZOJ 1821 [JSOI2010]Group 部落划分(kruskal)