Skip to content

102. Binary Tree Level Order Traversal - #26

Open
hiroki-horiguchi-dev wants to merge 1 commit into
mainfrom
tree-bst-102
Open

102. Binary Tree Level Order Traversal#26
hiroki-horiguchi-dev wants to merge 1 commit into
mainfrom
tree-bst-102

Conversation

@hiroki-horiguchi-dev

Copy link
Copy Markdown
Owner

Comment thread tree-bst/102.md
List<Integer> temp = new ArrayList<>();
while (nodes.peekFirst() != null
&& nodes.peekFirst().depth == depth) {
TreeNodeAndDepth nodeAndDepth = nodes.pollFirst();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

インデントが深すぎるかと思います。

@hiroki-horiguchi-dev hiroki-horiguchi-dev Jun 7, 2026

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.

ありがとうございます、そうですね。
2ndでだいぶ削れたので、修正できている認識です。

上記↑じゃなくて、シンプルにインデントが深いって話ですかね。。
であれば、leetcode のサイト上で解いたので条件箇所と分けるために一段インデント深くしてました。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

後者の意味でした。以下のようにすると良いと思います。

            while (nodes.peekFirst() != null
                    && nodes.peekFirst().depth == depth) {
                TreeNodeAndDepth nodeAndDepth = nodes.pollFirst();

@hiroki-horiguchi-dev hiroki-horiguchi-dev self-assigned this Jun 7, 2026
Comment thread tree-bst/102.md
nodes.addLast(root);
while (!nodes.isEmpty()) {
int size = nodes.size();
List<Integer> tempList = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

自分なら valsInLevel と名付けると思います。 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