计算二叉树的最大深度

我的方法是找出两个子树的长度中最长的那个,然后加1

 class Solution {
public:
int maxDepth(TreeNode* root) {
if(!root) return ;
else return max(maxDepth(root->left)+,maxDepth(root->right)+);
}
};

Leetcode 104 Maximum Depth of Binary Tree 二叉树的更多相关文章

  1. leetcode 104 Maximum Depth of Binary Tree二叉树求深度

    Maximum Depth of Binary Tree Total Accepted: 63668 Total Submissions: 141121 My Submissions Question ...

  2. [LeetCode] 104. Maximum Depth of Binary Tree 二叉树的最大深度

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  3. LeetCode 104. Maximum Depth of Binary Tree二叉树的最大深度 C++/Java

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  4. [LeetCode] 104. Maximum Depth of Binary Tree ☆(二叉树的最大深度)

    描述 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the l ...

  5. LeetCode 104. Maximum Depth of Binary Tree C++ 解题报告

    104. Maximum Depth of Binary Tree -- Easy 方法 使用递归 /** * Definition for a binary tree node. * struct ...

  6. (二叉树 BFS DFS) leetcode 104. Maximum Depth of Binary Tree

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  7. LeetCode 104. Maximum Depth of Binary Tree (二叉树的最大深度)

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  8. Leetcode 104. Maximum Depth of Binary Tree(二叉树的最大深度)

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  9. leetCode 104.Maximum Depth of Binary Tree(二叉树最大深度) 解题思路和方法

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

随机推荐

  1. jquery如何实现动态增加选择框

    jquery如何实现动态增加选择框 一.总结 一句话总结:用jquery的clone(true)方法. 1.如何在页面中复制amazeui加了特效的标签? amazeui中的控件带js方法,不知道那部 ...

  2. JavaWeb网站技术架构

    JavaWeb网站技术架构总结   题记 工作也有几多年了,无论是身边遇到的还是耳间闻到的,多多少少也积攒了自己的一些经验和思考,当然,博主并没有太多接触高大上的分布式架构实践,相对比较零碎,随时补充 ...

  3. mysql 查询字段名所在的表

    select * from (select * from information_schema.COLUMNS where table_schema = '数据库名') temp where colu ...

  4. linux系统下安装与配置apache

    搭建环境:VMware上虚拟的linux 主机:win  7 安装linux下的Apache前准备: 1.httpd服务的配置文件,默认存储路径:/etc/httpd/conf/httpd.conf( ...

  5. JAVA中try-catch异常逃逸

    有时候一些小的细节,确实比较纠结,对于try-catch-finally代码块中代码依次执行,当try中有exception抛出时,将会有catch拦截并执行,如果没有catch区块,那么except ...

  6. Android事件分发机制具体解释

    转载注明出处:http://blog.csdn.net/xiaohanluo/article/details/52416141 1. 概述 Android日常研发时,与View接触占领相当多的时间.而 ...

  7. [JS Compose] 1. Refactor imperative code to a single composed expression using Box

    After understanding how Box is, then we are going to see how to use Box to refacotr code, to un-nest ...

  8. Notepad++打开xml文件显示crlf的问题

    如图所示,显示CRLF,  CRLF其实是换行符. 所以在下图所示设置下显示行尾符不显示即可.

  9. php Apache配置伪静态的介绍

    以下是摘抄http://jingyan.baidu.com/article/86112f132aa7462737978718.html的,作为记录,方便以后参考 现有的在线网上视频教程对伪静态的讲解比 ...

  10. 判断系统64位(使用GetNativeSystemInfo函数,XP时代就有这个函数了)

    判断系统64位 static bool IsWin64 (void) { SYSTEM_INFO si = {0}; typedef void (WINAPI *LPFN_PGNSI)(LPSYSTE ...