Given a binary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int dfs(TreeNode *r){
if(r==NULL){
return ;
}
return max(dfs(r->left),dfs(r->right)) + ;
} int maxDepth(TreeNode* root) {
return dfs(root);
}
};

最新文章

  1. 再看ftp上传文件
  2. 帆布指纹识别(canvas fingerprinting)
  3. CF459B Pashmak and Flowers (水
  4. android 事件处理概念簇
  5. HD1046An Easy Task
  6. Android隐藏状态栏实现沉浸式体验
  7. Asp.Net HttpApplication请求管道与Session(二)
  8. Asset Catalog Creator Free 生成程序内图标的软件
  9. 【01-14】java ThreadLocal工具类
  10. 【转载】C# 获取系统时间及时间格式
  11. Java基础恶补——内存泄露、内存溢出
  12. .NET Core微服务之路:让我们对上一个Demo通讯进行修改,完成RPC通讯
  13. selenium APi
  14. Oracle EBS 计划请求
  15. Python数据挖掘——基础知识
  16. C++入门(1)
  17. SpringMVC札集(09)——拦截器
  18. C# 3.0-c#5.0 变化
  19. 使用 ceph 作为 openstack 的后端
  20. redis的安装和启动linux环境

热门文章

  1. Realm多线程中的那些坑...
  2. javascript判断智能终端信息
  3. ubuntu 下开源安装
  4. js 组合键监听ctrl + enter
  5. Redis系列-存储篇list主要操作函数小结(转)
  6. Linux系统运维之路
  7. [jjzhu学java]之solr4.9同步mysql数据
  8. 网页图表类框架(插件)——百度eCharts和Highcharts
  9. C#中的let字句应用示例
  10. .net调用存储过程详解(转载)