LeetCode 104 Maximum Depth of Binary Tree
2016-03-13 15:07
176 查看
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.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
public int maxDepth(TreeNode root) { if (root == null) { return 0; } else return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1; }
相关文章推荐
- 如何在win7下远程控制ubuntu
- 7.多态
- Qt发布错误:无法定位程序输入点于动态链接库QtCore5.dll
- 类String的构造函数、析构函数和赋值函数
- Maven快速入门
- Android的Binder的起源-android学习之旅(100)
- Android的Binder的起源-android学习之旅(100)
- Android的Binder的起源-android学习之旅(100)
- Deep learning:三十(关于数据预处理的相关技巧)
- Deep learning:二十九(Sparse coding练习)
- C99新特性:变长数组(VLA)
- Linux内核及分析 第三周 Linux内核的启动过程
- 6.面向对象的三大特征
- Arch Linux 安装过程
- JDK1.5后的新特性之一:可变参数
- const和typedef的常见用法详解
- java核心数据结构总结
- Android中JSON数据的解析
- HBase Snapshot解析
- 第三周项目-百钱买百鸡