Skip to content

Commit 25d83af

Browse files
author
binbin.hou
committed
[Feature] add for new
1 parent afcfd0f commit 25d83af

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ leetcode 算法笔记。
8484

8585
# 101-200
8686

87-
| 序号 | 难题 | 解决方案 | 速度% & 内存% | 时间 | 难度 |
88-
|:----|:---------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------|:-------------------|:-----|
89-
| 101 | [symmetric-tree](doc/101-200/101-symmetric-tree.md) | [java](https://github.com/houbb/leetcode/blob/master/src/main/java/com/github/houbb/leetcode/F100T200/T101_SymmetricTree.java) | [100 & 88.82](https://leetcode.com/problems/symmetric-tree/submissions/870298167/) | 2023-1-3 16:08:16 | EASY |
90-
| 102 | [binary-tree-level-order-traversal](doc/101-200/102-binary-tree-level-order-traversal.md) | [java](https://github.com/houbb/leetcode/blob/master/src/main/java/com/github/houbb/leetcode/F100T200/T102_BinaryTreeLevelOrderTraversal.java) | [100 & 99.99](https://leetcode.com/problems/binary-tree-level-order-traversal/submissions/468533749/) | 2021-3-16 21:37:16 | MEDIUM |
91-
| 103 | [binary-tree-zigzag-level-order-traversal](doc/101-200/103-binary-tree-zigzag-level-order-traversal.md) | [java](https://github.com/houbb/leetcode/blob/master/src/main/java/com/github/houbb/leetcode/F100T200/T103_BinaryTreeZigZagLevelOrderTraversal.java) | [100 & 99.99](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/submissions/468942448/) | 2021-3-17 19:54:16 | MEDIUM |
87+
| 序号 | 难题 | 解决方案 | 速度% & 内存% | 时间 | 难度 |
88+
|:----|:---------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------|:--------------------|:-----|
89+
| 101 | [symmetric-tree](doc/101-200/101-symmetric-tree.md) | [java](https://github.com/houbb/leetcode/blob/master/src/main/java/com/github/houbb/leetcode/F100T200/T101_SymmetricTree.java) | [100 & 88.82](https://leetcode.com/problems/symmetric-tree/submissions/870298167/) | 2023-01-03 16:08:16 | EASY |
90+
| 102 | [binary-tree-level-order-traversal](doc/101-200/102-binary-tree-level-order-traversal.md) | [java](https://github.com/houbb/leetcode/blob/master/src/main/java/com/github/houbb/leetcode/F100T200/T102_BinaryTreeLevelOrderTraversal.java) | [100 & 99.99](https://leetcode.com/problems/binary-tree-level-order-traversal/submissions/468533749/) | 2021-03-16 21:37:16 | MEDIUM |
91+
| 103 | [binary-tree-zigzag-level-order-traversal](doc/101-200/103-binary-tree-zigzag-level-order-traversal.md) | [java](https://github.com/houbb/leetcode/blob/master/src/main/java/com/github/houbb/leetcode/F100T200/T103_BinaryTreeZigZagLevelOrderTraversal.java) | [100 & 99.98](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/submissions/468942448/) | 2021-03-17 19:54:16 | MEDIUM |
92+
| 104 | [maximum-depth-of-binary-tree](doc/101-200/104-maximum-depth-of-binary-tree.md) | [java](https://github.com/houbb/leetcode/blob/master/src/main/java/com/github/houbb/leetcode/F100T200/T104_MaximumDepthOfBinaryTree.java) | [100 & 42.64](https://leetcode.com/problems/maximum-depth-of-binary-tree/submissions/870313682/) | 2023-01-03 16:42:16 | EASY |
9293

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
https://leetcode.com/problems/maximum-depth-of-binary-tree/description/
2+
3+
# 104. Maximum Depth of Binary Tree
4+
5+
Given the root of a binary tree, return its maximum depth.
6+
7+
A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
8+
9+
# Example
10+
11+
example 1:
12+
13+
![ex1](https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg)
14+
15+
```
16+
Input: root = [3,9,20,null,null,15,7]
17+
Output: 3
18+
```
19+
20+
example 2:
21+
22+
```
23+
Input: root = [1,null,2]
24+
Output: 2
25+
```
26+
27+
# Constraints:
28+
29+
The number of nodes in the tree is in the range [0, 10^4].
30+
-100 <= Node.val <= 100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.github.houbb.leetcode.F100T200;
2+
3+
import com.github.houbb.leetcode.component.TreeNode;
4+
5+
/**
6+
* 思路:
7+
*
8+
* 1. 遍历一棵树,然后到最后一层,就是最大的长度
9+
* 2. 应该使用哪一种遍历?
10+
*/
11+
public class T104_MaximumDepthOfBinaryTree {
12+
13+
public int maxDepth(TreeNode root) {
14+
if(root == null) {
15+
return 0;
16+
}
17+
18+
// 递归左右
19+
// 递归真的是神!
20+
return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
21+
}
22+
23+
24+
25+
}

0 commit comments

Comments
 (0)