111. Minimum Depth of Binary Tree
来源:互联网 发布:vb的flag 编辑:程序博客网 时间:2024/04/29 23:23
T
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.
S
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */int minDepth(struct TreeNode* root) { if (root == NULL) { return 0; } if (root->left == NULL) { return minDepth(root->right) + 1; } if (root->right == NULL) { return minDepth(root->left) + 1; } int l = minDepth(root->left) + 1; int r = minDepth(root->right) + 1; return (l > r ? r : l);}
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
- 111.Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- [leetcode] 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree LeetCode
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 【LeetCode】111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- LeetCode *** 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 编译提示"_sqlite3_column_int", referenced from: 错误 ---IOS中添加sqlite报错
- android之内存泄漏检测和解决方法及LeakCanary使用
- Redis 基础
- 时间转换问题1:cst 2015 String类型转换为Date类型
- HTML5页面操作android页面的方法(二)
- 111. Minimum Depth of Binary Tree
- 在windows server 2008r2上实现远程桌面
- 《天堂电影院》
- Javascript异步编程的4种方法
- JVM学习(2)--垃圾收集器
- MySQL触发器使用详解
- 在Ubuntu14.04上OpenStack Juno安装部署
- H5与Activity之间的通信(调用)
- Spring-cloud & Netflix 源码解析:Eureka 服务注册发现接口 ****