104. Maximum Depth of Binary Tree
2016-02-10 23:07
148 查看
深度优先搜索,迭代求子树深度
public class Solution {
public int maxDepth(TreeNode root) {
if(root==null){
return 0;
}
int left=maxDepth(root.left);
int right=maxDepth(root.right);
return Math.max(left,right)+1;
}
}
public class Solution {
public int maxDepth(TreeNode root) {
if(root==null){
return 0;
}
int left=maxDepth(root.left);
int right=maxDepth(root.right);
return Math.max(left,right)+1;
}
}
相关文章推荐
- Jquery插件开发方法
- Linux进程 -- exec函数操作
- SHUOJ 1013 过河卒问题 (递推)
- python切割nginx日志脚本
- LoaderManager使用详解(一)---没有Loader之前的世界
- nginx1.6.2编译安装
- MySQL批量删除指定前缀表
- java基础02
- php字符串函数总结 -未完
- PIC32MZ tutorial -- UART Communication
- 258. Add Digits
- MySQL多实例启停脚本
- hdu1161 (java中处理字符大小写转换)
- MySQL监控指标
- 深浅拷贝,赋值
- mysql多实例实例化数据库
- 来,让我们写一个网络爬虫,下载页面上所有的照片吧!
- 292. Nim Game
- mysql多实例配置文件
- 需要决断