We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9a40cd4 commit 027a40bCopy full SHA for 027a40b
solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/Solution.java
@@ -27,20 +27,20 @@ public Node connect(Node root) {
27
return root;
28
}
29
Deque<Node> q = new ArrayDeque<>();
30
- q.offer(root);
+ q.offerLast(root);
31
while (!q.isEmpty()) {
32
Node p = null;
33
for (int n = q.size(); n > 0; --n) {
34
- Node node = q.poll();
+ Node node = q.pollFirst();
35
if (p != null) {
36
p.next = node;
37
38
p = node;
39
if (node.left != null) {
40
- q.offer(node.left);
+ q.offerLast(node.left);
41
42
if (node.right != null) {
43
- q.offer(node.right);
+ q.offerLast(node.right);
44
45
46
0 commit comments