Skip to content

Commit 49e7491

Browse files
committed
주석
1 parent 97c514d commit 49e7491

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

maximum-depth-of-binary-tree/changhyumm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
# self.right = right
77
class Solution:
88
def maxDepth(self, root: Optional[TreeNode]) -> int:
9+
# root가 없는경우 depth 0
910
if root is None:
1011
return 0
12+
# depth를 같이 포함시킴
13+
# dfs의 경우 각 경로별로 끝까지 탐색하는데, 각 경로마다 depth가 다르므로 표기하면서 stack에 추가해야함
1114
stack = [[root, 1]]
1215
max_depth = 1
1316
while stack:

0 commit comments

Comments
 (0)