Skip to content

Conversation

hroc135
Copy link
Owner

@hroc135 hroc135 commented Oct 20, 2024

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

Choose a reason for hiding this comment

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

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

Copy link
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

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