Skip to content

102. Binary Tree Level Order Traversal#25

Open
hroc135 wants to merge 3 commits intomainfrom
102BinaryTreeLevelOrderTraversal
Open

102. Binary Tree Level Order Traversal#25
hroc135 wants to merge 3 commits intomainfrom
102BinaryTreeLevelOrderTraversal

Conversation

@hroc135
Copy link
Copy Markdown
Owner

@hroc135 hroc135 commented Oct 20, 2024

if root == nil {
return [][]int{}
}
nodeValuesByLevel := make([][]int, 0, 2000)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

マジックナンバーは定数にしたいなと思いました。

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.

ちょうど先ほど別問題で似たような指摘を受けました
定数にする or 定めない の選択肢がありますが、最大要素数が2000程度ならそんなに実行時間の短縮に効果が期待できないのでキャパシティを定めなくていいかなと思いました

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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