Skip to content

103. Binary Tree Zigzag Level Order Traversal - #26

Open
miyataka wants to merge 1 commit into
mainfrom
103_BinaryTreeZigzagLevelOrderTraversal
Open

103. Binary Tree Zigzag Level Order Traversal#26
miyataka wants to merge 1 commit into
mainfrom
103_BinaryTreeZigzagLevelOrderTraversal

Conversation

@miyataka

Copy link
Copy Markdown
Owner

@miyataka
miyataka force-pushed the 103_BinaryTreeZigzagLevelOrderTraversal branch from fed5243 to 347417b Compare July 13, 2026 18:35
- 他の人も書いているが読みやすい.
- 計算量についてふれてもいいかもしれない.N<=2000なので,心配するほどではないという捉え方もできる
- https://github.com/h-masder/Arai60/pull/30
- pythonの`[::-1]`とか全然知らなかったな

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

これはスライスですね。
公式ドキュメントは https://docs.python.org/ja/3.13/library/functions.html#slice あたりの認識です。

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.

返信が遅れました.
教えていただきありがとうございます.

@skypenguins

Copy link
Copy Markdown

全体的に読みやすいと思いました。

layerNum := 0
frontier := []*TreeNode{root}
for len(frontier) > 0 {
nextLayer := []*TreeNode{}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

frontier と nextLayer で、同じようなものを格納する変数の変数名に、異なる単語が使われているのが気になりました。自分なら frontier と nextFrontier と名付けると思います。好みの問題かもしれません。

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.

返信が遅れてすみません
たしかにそう思いました.次からそうします.

frontier := []*TreeNode{root}
for len(frontier) > 0 {
nextLayer := []*TreeNode{}
sameLayerVals := []int{}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

vals でも十分通じると思いました。

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