LeetCode——Minimum Depth of Binary Tree
来源:互联网 发布:淘宝名字大全英文名 编辑:程序博客网 时间:2024/05/01 16:18
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.
中文:给一二叉树,找出其最小深度。
最小深度是从根节点到最近的叶子节点的最短路径经过的节点的数量。
Java:
public int minDepth(TreeNode root) {if (root == null)return 0;int a = minDepth(root.left);int b = minDepth(root.right);if (a == 0)return b + 1;if (b == 0)return a + 1;return Math.min(a, b) + 1;}
0 0
- LeetCode——Minimum Depth of Binary Tree
- Minimum Depth of Binary Tree——LeetCode(Easy)
- LeetCode——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
- LeetCode111—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
- 编译fairscheduler
- POJ - 2688 Cleaning Robot
- log4net 配置
- OJ2445输入输出公有继承
- IOS绘图详解
- LeetCode——Minimum Depth of Binary Tree
- aop
- Leetcode 3Sum
- 哈夫曼编码
- JS获取input标签的text值、JS获取下拉框内容、input控制只能输入数字等问题汇总
- 第一次实验--NPC问题(回溯算法)
- checkio -- Three Points Circle
- Null value was assigned to a property of primitive type setter of com.ibeifeng.po.Employee.modifyTim
- 复数类加减乘除的运算符重载