111. Minimum Depth of Binary Tree
来源:互联网 发布:淘宝店铺代运营 编辑:程序博客网 时间:2024/06/04 01:21
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.
32%
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
int minDepth(struct TreeNode* root) {
int i,j;
if(!root)
return 0;
i = minDepth(root->left);
j = minDepth(root->right);
return i<j && i || !j ?i+1:j+1;
}
阅读全文
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
- 如何理解RDF?
- 使用 NIO 实现 echo 服务器
- Qt中的调色板
- 集合的一些知识点
- MMU
- 111. Minimum Depth of Binary Tree
- 基于Spring Boot和Spring Cloud实现微服务架构学习(三)-Spring Boot应用
- LVS之-LAMP搭建wordpress
- select 和 poll基本用法
- linux permission denied解决方法
- 服务器定时执行计划任务(通过浏览器请求某个链接)
- Android ViewGroup事件分发机制学习笔记
- ArrayList在内存中的存储方式(图解)
- Tomcat容器管理安全的几种验证方式