【Leetcode】Maximum Depth of Binary Tree
来源:互联网 发布:php quot 转成符号 编辑:程序博客网 时间:2024/05/16 05:21
题目链接:https://leetcode.com/problems/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.
思路:
递归左右子树高度
算法:
public int maxDepth(TreeNode root) {if (root == null)return 0;int h1 = maxDepth(root.left);int h2 = maxDepth(root.right);return h1 > h2 ? h1 + 1 : h2 + 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
- 基于linux系统下的SVN服务安装
- Servlet的url-pattern匹配规则
- 《c语言从入门到精通》看书笔记——第12章 位运算
- 简单实现spring里的BeanFactory实现原理
- 逐帧动画
- 【Leetcode】Maximum Depth of Binary Tree
- <LeetCode><Medium>2 Add Two Numbers
- 仿美团加载动画效果
- 用例子理解hibernate的一级缓存
- 通过AVFoundation获取摄像头数据[Swift]
- [Django架构流程分析]请求处理机制其二:Django中间件的解析
- 排序算法学习总结
- 常见HTTP状态码
- Python 的判断语句以及输入语句的使用