111. Minimum Depth of Binary Tree
来源:互联网 发布:轴系校中软件 编辑:程序博客网 时间:2024/06/06 10:58
/** * 111.Minimum Depth of Binary Tree * * Problem Description: * 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 a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { public int minDepth(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; return Math.min(minDepth(root.left), minDepth(root.right)) + 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
- iOS开发之基础视图——UIProgressView和UIProgressView
- WebDriver原理分析
- 【第七章】 对JDBC的支持 之 7.2 JDBC模板类 ——跟我学spring3
- 查看openwrt内核版本
- hdu 1856(并查集)
- 111. Minimum Depth of Binary Tree
- 指针阅读技巧学习笔记
- java实现map和Object互转
- Selenium中的几种等待方式,需特别注意implicitlyWait的用法
- Java并发编程:CountDownLatch、CyclicBarrier和Semaphore
- 序列化和反序列化
- 关于myfaces-1.1.1.jar
- 趣学 C 语言(六)—— 结构和联合
- Selenium Webdriver元素定位的方式