minimum-depth-of-binary-tree
来源:互联网 发布:linux的syslog开启 编辑:程序博客网 时间:2024/06/06 14:12
问题描述:
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.
解决方案:
class Solution { public: int run(TreeNode *root) { if(root==NULL)return 0; else { int i=run(root->left); int j=run(root->right); if(i==0||j==0) return 1+i+j; else return (i<j)?i+1:j+1; } }};
阅读全文
0 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
- 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
- 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
- Minimum Depth of Binary Tree
- Minimum Depth of Binary Tree
- Minimum Depth of Binary Tree
- adb shell命令输入dos窗口后,报错error:device not found
- Android中弱引用和软引用的应用场景
- MFC/OpenCV读取摄像头
- HDU_6154 CaoHaha's staff 【规律打表】
- UVA 1152 4 Values whose Sum is 0 (二分)
- minimum-depth-of-binary-tree
- AQS源码分析
- 2017电赛板球系统比赛经历
- SqlServer 2008中time类型的使用方法
- [opengl笔记]2017年08月19日
- CUDA 8.0 安装
- oracle中的部分要点
- Spring之路-初识IOC
- FCN