【LeetCode】Maximum Depth of Binary Tree
http://oj.leetcode.com/problems/maximum-depth-of-binary-tree/

public class Solution {
    public int maxDepth(TreeNode root) {
        if(root!=null){
            int depth=0;
            InOrder(root,depth);
        }
        return max;
    }
    public int max=0;
    private void InOrder(TreeNode root, int depth) {
        if(root!=null){
            depth++;
            if(max<depth){
                max=depth;
            }
            InOrder(root.left,depth);
            InOrder(root.right,depth);
            depth--;
        }
    }
}
【LeetCode】Maximum Depth of Binary Tree的更多相关文章
- 【LeetCode】Maximum Depth of Binary Tree(二叉树的最大深度)
		
这道题是LeetCode里的第104道题. 给出题目: 给定一个二叉树,找出其最大深度. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. 说明: 叶子节点是指没有子节点的节点. 示例: 给定 ...
 - 【LeetCode】Minimum Depth of Binary Tree   二叉树的最小深度 java
		
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...
 - 【Leetcode】【Easy】Maximum Depth of Binary Tree
		
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
 - 【leetcode】Minimum Depth of Binary Tree
		
题目简述: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along th ...
 - 【leetcode】Minimum Depth of Binary Tree (easy)
		
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...
 - 【LeetCode练习题】Maximum Depth of Binary Tree
		
Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the n ...
 - Leetcode | Minimum/Maximum Depth of Binary Tree
		
Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the n ...
 - leetcode 104 Maximum Depth of Binary Tree二叉树求深度
		
Maximum Depth of Binary Tree Total Accepted: 63668 Total Submissions: 141121 My Submissions Question ...
 - LeetCode 104. Maximum Depth of Binary Tree C++ 解题报告
		
104. Maximum Depth of Binary Tree -- Easy 方法 使用递归 /** * Definition for a binary tree node. * struct ...
 
随机推荐
- UPC 2219: A^X mod P
			
题形:另类快速幂 题意: f(x) = K, x = 1 f(x) = (a*f(x-1) + b)%m , x > 1 Now, Your task is to calculate ( A^( ...
 - 腾讯IM的那些坑
			
项目中接入腾讯IM,在这里记录下,以便大家解决问题时少走弯路 1.首先讲一下IM返回对象的问题: /** * 消息工厂方法 */ public static Message getMessage(TI ...
 - socket的accept: Invalid argument问题
			
void local_sdk_server::wait_remote_client_connect_and_comm() { /*服务器服务启动,等待客户端的链接的到来*/ //sockaddr_in ...
 - 网络入侵检测规避工具fragrouter
			
网络入侵检测规避工具fragrouter 网络入侵检测系统可以通过拦截数据包,获取内容进而判断是否为恶意数据包.对于传输较大的数据包,通常会采用分片的方式,将大数据包拆分为小数据包进行传输.如果入 ...
 - Java中使用new Date()和System.currentTimeMillis()获取当前时间戳的区别(转)(Java进阶-性能提升)
			
在开发过程中,通常很多人都习惯使用new Date()来获取当前时间,使用起来也比较方便,同时还可以获取与当前时间有关的各方面信息,例如获取小时,分钟等等,而且还可以格式化输出,包含的信息是比较丰富的 ...
 - Maven转换成Eclipse/Idea/MyEclipse工程,以及配置Web工程
			
Eclipse/MyEclipse: //Jar mvn eclipse:eclipse mvn eclipse:myeclipse //Web mvn eclipse:eclipse -Dwtpve ...
 - Java文件夹操作,判断多级路径是否存在,不存在就创建(包括windows和linux下的路径字符分析),兼容Windows和Linux
			
兼容windows和linux. 分析: 在windows下路径有以下表示方式: (标准)D:\test\1.txt (不标准,参考linux)D:/test/1.txt 然后在java中,尤其使用F ...
 - java IOUtils下载图片
			
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.Inp ...
 - arcgis andriod 加载影像
			
MapView mMapView;......String rasterPath = Environment.getExternalStorageDirectory().getPath() + &qu ...
 - SharePreferences使用
			
获取数据: @SuppressLint("InlinedApi") private String getFromSharePreference(String key) { if ( ...