Skip to content

Commit 8ff1f87

Browse files
authored
update Solution
1 parent 0bc0920 commit 8ff1f87

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

BFS/MaximumDepthOfBinaryTree.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,13 @@
2828
https://leetcode.com/problems/maximum-depth-of-binary-tree/description/
2929
3030
"""
31+
class Solution:
32+
33+
def maxDepth(self, root: TreeNode) -> int:
34+
if root is None:
35+
return 0
36+
else:
37+
left_height = self.maxDepth(root.left)
38+
right_height = self.maxDepth(root.right)
39+
return max(left_height, right_height) + 1
40+

0 commit comments

Comments
 (0)