Skip to content

Commit 7fd579d

Browse files
committed
maxDepth 계산 단순화
1 parent 855e2fc commit 7fd579d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ def maxDepth(self, root: Optional[TreeNode]) -> int:
99
if not root:
1010
return 0
1111

12-
left_max_dept = self.maxDepth(root.left) + 1
13-
right_max_dept = self.maxDepth(root.right) + 1
14-
15-
return max(left_max_dept, right_max_dept)
12+
return max(self.maxDepth(root.left), self.maxDepth(root.right)) + 1

0 commit comments

Comments
 (0)