Skip to content

Commit 633a9e0

Browse files
Update maximum-depth-of-binary-tree/dolphinflow86.py
오 넵 이게 낫겠네요! 변수를 쓴다면 더 명시적으로 적어보겠습니다. Co-authored-by: Hojeong Park <parkhj062@gmail.com>
1 parent 146a402 commit 633a9e0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ def dfs(self, node: Optional[TreeNode], depth: int) -> int:
1212
if not node:
1313
return depth
1414

15-
left = self.dfs(node.left, depth + 1)
16-
right = self.dfs(node.right, depth + 1)
17-
return max(left, right)
15+
return max(
16+
self.dfs(node.left, depth + 1),
17+
self.dfs(node.right, depth + 1)
18+
)
1819

1920
def maxDepth(self, root: Optional[TreeNode]) -> int:
2021
return self.dfs(root, 0)

0 commit comments

Comments
 (0)