104. Maximum Depth of Binary Tree
来源:互联网 发布:网络上sn是什么意思啊 编辑:程序博客网 时间:2024/05/02 01:49
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.
DFS
public class Solution { public int maxDepth(TreeNode root) { if(root == null) return 0; int left = 0,right = 0; if(root.left != null){ left = maxDepth(root.left); } if(root.right != null){ right = maxDepth(root.right); } return right >= left ? right+1:left+1; }}
0 0
- [LeetCode]104.Maximum Depth of Binary Tree
- 104.Maximum Depth of Binary Tree
- 【LeetCode】104.Maximum Depth of Binary Tree
- [Leetcode] 104. Maximum Depth of Binary Tree
- LeetCode --- 104. Maximum Depth of Binary Tree
- LeetCode 104. Maximum Depth of Binary Tree
- 104.Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree
- 104.Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree
- leetCode 104. Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree LeetCode
- 104. Maximum Depth of Binary Tree LeetCode
- 104. Maximum Depth of Binary Tree
- LeetCode 104. Maximum Depth of Binary Tree
- leetcode:104. Maximum Depth of Binary Tree
- 12.Swift 中的关键字详解
- 插入排序
- People CMM和抗日义勇军
- linux查看Tomcat连接数、统计某字段出现的次数
- Java 输入/输出流
- 104. Maximum Depth of Binary Tree
- Mac OS X EI Capitan下安装hadoop
- 阿里云存储封装类 AliYunOssUtility
- 面向对象编程:一个灾难性的故事
- hibernate之持久化类属性和访问方法分析
- 待产
- Spring3 整合Hibernate3.5 动态切换SessionFactory
- 考试培训市场的一些情况
- 笔记