diff --git a/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/README.md b/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/README.md index 7ea4dc4badcf5..26015f6a69f8e 100644 --- a/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/README.md +++ b/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/README.md @@ -148,20 +148,20 @@ class Solution { return root; } Deque q = new ArrayDeque<>(); - q.offer(root); + q.offerLast(root); while (!q.isEmpty()) { Node p = null; for (int n = q.size(); n > 0; --n) { - Node node = q.poll(); + Node node = q.pollFirst(); if (p != null) { p.next = node; } p = node; if (node.left != null) { - q.offer(node.left); + q.offerLast(node.left); } if (node.right != null) { - q.offer(node.right); + q.offerLast(node.right); } } } diff --git a/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/README_EN.md b/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/README_EN.md index a7373f198dc44..c2a9234d33f77 100644 --- a/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/README_EN.md +++ b/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/README_EN.md @@ -146,20 +146,20 @@ class Solution { return root; } Deque q = new ArrayDeque<>(); - q.offer(root); + q.offerLast(root); while (!q.isEmpty()) { Node p = null; for (int n = q.size(); n > 0; --n) { - Node node = q.poll(); + Node node = q.pollFirst(); if (p != null) { p.next = node; } p = node; if (node.left != null) { - q.offer(node.left); + q.offerLast(node.left); } if (node.right != null) { - q.offer(node.right); + q.offerLast(node.right); } } } diff --git a/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/Solution.java b/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/Solution.java index 1bbd53c899395..8bca8c04e5cbf 100644 --- a/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/Solution.java +++ b/solution/0100-0199/0117.Populating Next Right Pointers in Each Node II/Solution.java @@ -27,20 +27,20 @@ public Node connect(Node root) { return root; } Deque q = new ArrayDeque<>(); - q.offer(root); + q.offerLast(root); while (!q.isEmpty()) { Node p = null; for (int n = q.size(); n > 0; --n) { - Node node = q.poll(); + Node node = q.pollFirst(); if (p != null) { p.next = node; } p = node; if (node.left != null) { - q.offer(node.left); + q.offerLast(node.left); } if (node.right != null) { - q.offer(node.right); + q.offerLast(node.right); } } }