Skip to content

104. Maximum Depth of Binary Tree#15

Open
hiro111208 wants to merge 1 commit into
mainfrom
104-maximum-depth-of-binary-tree
Open

104. Maximum Depth of Binary Tree#15
hiro111208 wants to merge 1 commit into
mainfrom
104-maximum-depth-of-binary-tree

Conversation

@hiro111208
Copy link
Copy Markdown
Owner

Comment thread step1.md
def maxDepth(self, root: Optional[TreeNode]) -> int:
if root is None:
return 0
return 1 + max(self.maxDepth(root.right), self.maxDepth(root.left))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

個人的には a * x + b のような形を見慣れているので、

return max(self.maxDepth(root.right), self.maxDepth(root.left)) + 1

と書くことが多いです。趣味の範囲だと思います。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants