[LeetCode]Maximum Depth of Binary Tree
来源:互联网 发布:java使用http调用接口 编辑:程序博客网 时间:2024/06/05 23:55
题目描述
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.
求二叉树的最大深度。解题思路
递归
代码
public int maxDepth(TreeNode root) { if (root == null)return 0;return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1; }
0 0
- Leetcode - Tree - Maximum Depth of Binary Tree
- [leetcode][tree] Maximum Depth of Binary Tree
- LeetCode Maximum Depth of Binary Tree
- [Leetcode] Maximum Depth of Binary Tree
- leetcode 24: Maximum Depth of Binary Tree
- [LeetCode] Maximum Depth of Binary Tree
- Leetcode 104 Maximum Depth of Binary Tree
- 【leetcode】Maximum Depth of Binary Tree
- [leetcode]Maximum Depth of Binary Tree
- [LeetCode]Maximum Depth of Binary Tree
- [leetcode]Maximum Depth of Binary Tree
- Leetcode: Maximum Depth of Binary Tree
- LeetCode-Maximum Depth of Binary Tree
- [leetcode] Maximum Depth of Binary Tree
- LeetCode - Maximum Depth of Binary Tree
- LeetCode:Maximum Depth of Binary Tree
- LeetCode | Maximum Depth of Binary Tree
- 【leetcode】Maximum Depth of Binary Tree
- 自定义控件(一)
- require.js+backbone 使用r.js 在本地与生产环境 一键压缩的实现方式
- jquery实现文本点击修改
- leetcode: Reverse Linked List II
- TASK_INTERRUPTIBLE 和 TASK_UNINTERRUPTIBLE
- [LeetCode]Maximum Depth of Binary Tree
- 怎样才能成为优秀的前端开发工程师
- 黑马程序员:StringBuffer操作
- 网络,协议开发的福音,wireshark官方推荐各种网络包处理工具合集
- VC版超级记事本
- JAVA枚举
- .html(),.text()和.val()的使用
- ubuntu:显示grub菜单(ubuntu 12.04)
- C++的一种业务分发方案(另类的工厂模式)