leetcode: Maximum Depth of Binary Tree
来源:互联网 发布:日线里引用分时数据 编辑:程序博客网 时间:2024/06/07 19:36
104. Maximum Depth of Binary Tree
My SubmissionsTotal Accepted: 149038 Total Submissions: 309044 Difficulty: Easy
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.
迭代法:
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public int maxDepth(TreeNode root) { if(root == null) { return 0; } else{ return 1+Math.max(maxDepth(root.left),maxDepth(root.right)); } }}
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基本命令(56)——netstat命令
- <Notification>的功能与方法
- javascript改变外部css样式表
- leetcode: Maximum Depth of Binary Tree
- Kafka集群安装使用
- PPT制作树状结构图
- LeetCode-200.Number of Islands
- 主从DB与cache一致性
- 递归啦...
- 《数据结构及应用》总结(1)------数据结构
- IEEE 802.15.4协议完整中文版 - 4.5 功能概述
- Java clone() 浅克隆与深度克隆