## minimum Depth of Binary Tree 原

zhuguorong

``````/*
* The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
* */
public class Solution {

public static void main(String[] args) {
// TODO Auto-generated method stub

}
public int minDepth(TreeNode root) {
if(root == null)
return 0;
int left = minDepth(root.left);
int right = minDepth(root.right);//最短路径是最靠近根的叶子深度
if(Math.min(left, right)>0)
return Math.min(left, right)+1;
else
return Math.max(left, right)+1;
}

}
class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x)
{
val = x;
}
}``````

### zhuguorong

Leetcode——二叉树常考算法整理

qq_32690999
2018/05/28
0
0

2016/12/21
0
0
Leetcode 二叉树解题报告

1. Binary Tree Preorder Traversal Description Given a binary tree, return the preorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 2 / 3 Output: [1,2,3] Analy......

BookThief
2018/07/29
0
0

qq_32690999
2018/01/25
0
0

2017/08/05
0
0

7分钟前
0
0
Linux运维常见的硬件及系统问题

15分钟前
0
0
Confluence 6 针对 'unmigrated-wiki-markup' 宏重新尝试合并

honeymoose
25分钟前
0
0
ubuntu 18.04桌面版启动错误： Unable to mount root fs on unknown-block(0,0)

wwzzhh166
26分钟前
0
0
fescar select for update 读隔离级别实现

/* * Copyright 1999-2018 Alibaba Group Holding Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in complian......

xiaomin0322
29分钟前
0
0