LeetCode_104Maximum Depth of Binary Tree
来源:互联网 发布:sql 安全策略 编辑:程序博客网 时间:2024/04/28 07:16
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 int maxDepth(TreeNode root) { if (root == null) return 0; int l = maxDepth(root.left); int r = maxDepth(root.right); return l > r? l+1:r+1; }
0 0
- LeetCode_104Maximum Depth of Binary Tree
- Depth of binary tree
- Minimum Depth of Binary Tree,Maximum Depth of Binary Tree
- LeetCode: Depth of Binary Tree
- Maximum Depth of Binary Tree
- Minimum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Minimum Depth of Binary Tree
- Minimum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Minimum Depth of Binary Tree
- Minimum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Minimum Depth of Binary Tree
- Minimum Depth of Binary Tree
- Maximum Depth of Binary Tree
- 查看linux发行版本
- 水晶报表相关代码
- 数据库索引
- 判断ScrolllView是否滑动到底部和顶部
- magento学习索引
- LeetCode_104Maximum Depth of Binary Tree
- android ziputil
- Inline Assembly Intro - Register Mismatch
- ROS学习(一) 安装ROS indigo
- Magento使用php shell 命令更新索引(index)
- Block的学习笔记2
- 二分图匹配
- OSChina客户端源码学习(2)--缓存的设计
- Linux下搭建Apache+php+MongoDB开发环境