minimum-depth-of-binary-tree java code
来源:互联网 发布:极点五笔 mac 编辑:程序博客网 时间:2024/06/05 20:46
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.
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public int predepth(TreeNode root){ if(root==null){ return 0; } if(root.left==null){ return predepth(root.right)+1; } if(root.right==null){ return predepth(root.left)+1; } return Math.min(predepth(root.left),predepth(root.right))+1; } public int run(TreeNode root) { return predepth(root); }}
阅读全文
0 0
- minimum-depth-of-binary-tree java code
- CODE 22: Minimum Depth of Binary Tree
- [leet code] Minimum Depth of Binary Tree
- [Leetcode] Minimum Depth of Binary Tree (Java)
- Minimum Depth of Binary Tree Java
- Minimum Depth of Binary Tree (Java)
- Minimum Depth of Binary Tree Java
- [LeetCode][Java] Minimum Depth of Binary Tree
- LeetCode|Minimum Depth of Binary Tree-java
- (java)Minimum Depth of Binary Tree
- leetcode:Minimum Depth of Binary Tree 【Java】
- maximum-depth-of-binary-tree Java code
- leetcode 日经贴,Cpp code -Minimum Depth of Binary Tree
- Lee天Code : 111. 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
- RecyclerView实现多种布局与OkHttp结合获取数据
- Linux Centos 6.5网络启动不起来Bringing up interface eth0: Error
- Leetcode4. Median of Two Sorted Arrays
- Linux进程调度学习1
- pycharm忽略文件夹方法
- minimum-depth-of-binary-tree java code
- 正确理解使用Vue里的nextTick方法
- Ubuntu系统升级系统Unable to find expected entry 'main/binary-i386sudo/Packages'in...
- 高精度练习之减法
- js基础知识(二)
- java常用的框架介绍
- 004_ServletConfig详解
- 恒嘉从笔试到面试感悟
- LoadRunner常用问题解决方法