FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode-study/maximum-depth-of-binary-tree/Yiseull.java at main · DaleStudy/leetcode-study · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DaleStudy
/
leetcode-study
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
361
Star
155
Code
Issues
75
Pull requests
5
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode-study
/
maximum-depth-of-binary-tree
/
Yiseull.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (26 loc) · 619 Bytes
Breadcrumbs
leetcode-study
/
maximum-depth-of-binary-tree
/
Yiseull.java
Copy path
File metadata and controls
29 lines (26 loc) · 619 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
*/
class
Solution
{
public
int
maxDepth
(
TreeNode
root
) {
return
dfs
(
root
);
}
private
int
dfs
(
TreeNode
node
) {
if
(
node
==
null
) {
return
0
;
}
return
1
+
Math
.
max
(
dfs
(
node
.
left
),
dfs
(
node
.
right
));
}
}
Back
|
FazBrowse Home
|
New Git URL