FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode-study/maximum-depth-of-binary-tree/JeonJe.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
/
JeonJe.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
15 lines (13 loc) · 434 Bytes
Breadcrumbs
leetcode-study
/
maximum-depth-of-binary-tree
/
JeonJe.java
Copy path
File metadata and controls
15 lines (13 loc) · 434 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
import
java
.
util
.*;
// TC: O(n)
// SC: O(h)
class
Solution
{
public
int
maxDepth
(
TreeNode
root
) {
return
calMaxDepth
(
root
);
}
// 현재까지 최대 깊이는 Math.max(왼쪽 서브노드 최대 깊이 , 오른쪽 서브노드 최대깊이) + 1
private
int
calMaxDepth
(
TreeNode
node
) {
if
(
node
==
null
)
return
0
;
return
Math
.
max
(
calMaxDepth
(
node
.
left
),
calMaxDepth
(
node
.
right
)) +
1
;
}
}
Back
|
FazBrowse Home
|
New Git URL