Skip to content

Create 104. Maximum Depth of Binary Tree.md#6

Merged
Mike0121 merged 1 commit intomainfrom
104.-Maximum-Depth-of-Binary-Tree
Nov 1, 2025
Merged

Create 104. Maximum Depth of Binary Tree.md#6
Mike0121 merged 1 commit intomainfrom
104.-Maximum-Depth-of-Binary-Tree

Conversation

@Mike0121
Copy link
Copy Markdown
Owner

@Mike0121 Mike0121 commented May 1, 2024

Copy link
Copy Markdown

@nodchip nodchip left a comment

Choose a reason for hiding this comment

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

よいと思います。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2回目の解法は普通にPreorderなDFSじゃないですか?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ご指摘のとおりですね。DFSでした。
BFSにするには、.pop(0)ですね。細かいところまで見て頂いてありがとうございます。

Comment on lines 65 to 68
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

教科書的なPreorderのDFSだと左側のノードから見ると思うので、node_stackに追加する順番が逆の方が個人的には好みです。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

なるほどです。こちらも参考になります。確かにその方が良いですね。
ありがとうございます。

@Mike0121 Mike0121 changed the title 104. Maximum Depth of Binary Tree.md Create 104. Maximum Depth of Binary Tree.md Nov 1, 2025
@Mike0121 Mike0121 merged commit 170c124 into main Nov 1, 2025
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.

3 participants