leetcode minimum-depth-of-binary-tree
来源:互联网 发布:js获取本地服务器地址 编辑:程序博客网 时间:2024/06/11 06:36
题目描述
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.
import java.util.*;public class Solution { public int run(TreeNode root) { if( root == null) return 0; if( root != null && root.left == null && root.right == null) return 1;if( root.left == null ) return run( root.right)+1; if( root.right == null ) return run( root.left)+1; return Math.min(run(root.left),run(root.right))+1; }}
0 0
- 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
- 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
- LeetCode | Minimum Depth of Binary Tree
- LeetCode - Minimum Depth of Binary Tree
- java中List,ArrayList,LinkedList的常用方法
- 剑指Offer--051-数组中重复的数字
- 【神奇的C++】求a
- 2016.5.30 jd算法面试题
- iOS RTMP 视频直播开发笔记(6)- 封包 FLV
- leetcode minimum-depth-of-binary-tree
- HDOJ 5430 Three Palindromes
- 强悍的 Vim —— .vimrc(vim 配置文件)
- codeforces 667A A. Pouring Rain(水题)
- jdk8中tomcat修改配置PermSize为MetaspaceSize
- Spring MVC测试框架详解——服务端测试
- No mapping found for HTTP request with URI [/index.html] in DispatcherServlet with name 'springmvc'
- poj之旅——1258,2377,2395
- Android删除锁屏密码