From 027a40b407a3927e313050d4efaa1513c1376127 Mon Sep 17 00:00:00 2001 From: waitpersistence <146935713+waitpersistence@users.noreply.github.com> Date: Sun, 9 Nov 2025 05:07:49 +0000 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8offerLast?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3offer=E4=BB=A5=E6=8F=90=E5=8D=87=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Solution.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); } } } From 2c781aa971b8e9d3d70de24ad72d55e3b0296b38 Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Sun, 9 Nov 2025 18:32:35 +0800 Subject: [PATCH 2/3] Refactor queue operations to use offerLast --- .../README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); } } } From 53a02548a148f30169fc402ba487dfbb8de642a1 Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Sun, 9 Nov 2025 18:33:29 +0800 Subject: [PATCH 3/3] Update queue methods for node traversal --- .../README_EN.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); } } }