( Leetcode 104 ) Maximum Depth of Binary Tree
来源:互联网 发布:网贷数据交易平台 编辑:程序博客网 时间:2024/05/17 00:54
题目:Maximum Depth of Binary Tree
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.
解题思路:这是一道很简单常用的数据结构题,简单来说通过递归方法就可以求出来。下面直接看代码吧。
Java代码:
public class Solution { public int maxDepth( TreeNode root ) { if( root == null ) { return 0; } int ldep = maxDepth( root.left );int rdep = maxDepth( root.right );return ldep > rdep ? ldep+1 : rdep+1; }}
程序运行时间 0 ms。
0 0
- Leetcode 104 Maximum Depth of Binary Tree
- LeetCode(104)Maximum Depth of Binary Tree
- LeetCode 104 Maximum Depth of Binary Tree
- LeetCode: Maximum Depth of Binary Tree [104]
- 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
- 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
- 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
- Leetcode #104 Maximum Depth of Binary Tree
- leetcode 104: Maximum Depth of Binary Tree
- 评分组件
- websphere 启动服务
- Linux下的TCP/IP编程----UDP篇
- Activity生命周期
- 查看CentOS系统版本是32位的还是64位的
- ( Leetcode 104 ) Maximum Depth of Binary Tree
- Android中更安全的使用AsyncTask
- 文字转换为二进制/十六进制(Uncode编码 java实现)
- getter-setter方法/点语法
- Python3 爬虫(一)-- 简单网页抓取
- 面试问题
- 消息通道looper
- Android权限适配方案(API 4+)
- 使用FFTW的fftw_plan_dft_c2r_1d()由于未归一化结果错误的解决方案