Skip to content

Commit 027a40b

Browse files
refactor: 使用offerLast替代offer以提升代码规范性
1 parent 9a40cd4 commit 027a40b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/Solution.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ public Node connect(Node root) {
2727
return root;
2828
}
2929
Deque<Node> q = new ArrayDeque<>();
30-
q.offer(root);
30+
q.offerLast(root);
3131
while (!q.isEmpty()) {
3232
Node p = null;
3333
for (int n = q.size(); n > 0; --n) {
34-
Node node = q.poll();
34+
Node node = q.pollFirst();
3535
if (p != null) {
3636
p.next = node;
3737
}
3838
p = node;
3939
if (node.left != null) {
40-
q.offer(node.left);
40+
q.offerLast(node.left);
4141
}
4242
if (node.right != null) {
43-
q.offer(node.right);
43+
q.offerLast(node.right);
4444
}
4545
}
4646
}

0 commit comments

Comments
 (0)