Create 103. Binary Tree Zigzag Level Order Traversal.md#30
Open
irohafternoon wants to merge 1 commit intomainfrom
Open
Create 103. Binary Tree Zigzag Level Order Traversal.md#30irohafternoon wants to merge 1 commit intomainfrom
irohafternoon wants to merge 1 commit intomainfrom
Conversation
Fuminiton
reviewed
Apr 29, 2025
| next_nodes.push_back(node->right); | ||
| } | ||
| } | ||
| std::swap(current_nodes, next_nodes); |
There was a problem hiding this comment.
個人的には、next_nodesをcurrent_nodesに渡す時点でreverseさせておきたくなります。
与えられた配達リストを奇数日なら後ろから配達して、偶数日なら上から配達してくださいという依頼にみえます。上から配達してもらうための配達リストを渡すのが自然だと思います。
| } | ||
| return zigzag_ordered_lists; | ||
| } | ||
| }; |
oda
reviewed
Apr 29, 2025
| std::vector<TreeNode*> next_nodes; | ||
| zigzag_ordered_values.emplace_back(); | ||
| for (auto node : current_nodes) { | ||
| zigzag_ordered_values[current_level].push_back(node->val); |
Owner
Author
There was a problem hiding this comment.
ありがとうございます。
リファレンスを確認しました
https://cplusplus.com/reference/vector/vector/back/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Problem
Binary Tree Zigzag Level Order Traversal
Next Problem
Validate Binary Search Tree