Skip to content

【Arai60】27問目 103. Binary Tree Zigzag Level Order Traversal#27

Merged
shining-ai merged 3 commits intomainfrom
review27
Jun 29, 2024
Merged

【Arai60】27問目 103. Binary Tree Zigzag Level Order Traversal#27
shining-ai merged 3 commits intomainfrom
review27

Conversation

@shining-ai
Copy link
Copy Markdown
Owner

Copy link
Copy Markdown

@hayashi-ay hayashi-ay left a comment

Choose a reason for hiding this comment

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

良いと思います。

node_queue.append(node.left)
if node.right:
node_queue.append(node.right)
if level % 2 == 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.

これは好みですね。

Suggested change
if level % 2 == 1:
if level % 2:

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.

なるほど、確かにその書き方もできますね。
この選択肢は頭にありませんでした。

Comment on lines +12 to +13
node = node_queue.popleft()
nodes.append(node.val)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

このnodeとこのnodesで中の値が違うのがちょっと気になる気もします。nodesなのでTreeNodeのlistなのかなと思いきや実際にはintの配列なので。

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.

nodesは誤解される名前でしたね。
values_in_levelにしてみます。

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