From b124befd1263689d1078a3417cd10cbf5ce2aebe Mon Sep 17 00:00:00 2001 From: chenhaoran14 <2718827494@qq.com> Date: Thu, 20 Jan 2022 01:15:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AF=B9Java=E7=9A=84=E5=A4=A7=E9=A1=B6?= =?UTF-8?q?=E5=A0=86=E5=92=8C=E5=B0=8F=E9=A1=B6=E5=A0=86=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=BA=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0347.前K个高频元素.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/0347.前K个高频元素.md b/problems/0347.前K个高频元素.md index 0b8fd2d7..8bd774e9 100644 --- a/problems/0347.前K个高频元素.md +++ b/problems/0347.前K个高频元素.md @@ -142,7 +142,7 @@ class Solution { Set> entries = map.entrySet(); // 根据map的value值正序排,相当于一个小顶堆 - PriorityQueue> queue = new PriorityQueue<>((o1, o2) -> o2.getValue() - o1.getValue()); + PriorityQueue> queue = new PriorityQueue<>((o1, o2) -> o1.getValue() - o2.getValue()); for (Map.Entry entry : entries) { queue.offer(entry); if (queue.size() > k) { From 43eb0269d3dbbf47794eeee8690bcebae3d523db Mon Sep 17 00:00:00 2001 From: chenhaoran14 <2718827494@qq.com> Date: Thu, 20 Jan 2022 12:04:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AF=B9Java=E7=89=88=E6=9C=AC=E5=89=8D?= =?UTF-8?q?=E5=BA=8F=E6=8E=92=E5=88=97=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/二叉树的递归遍历.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/problems/二叉树的递归遍历.md b/problems/二叉树的递归遍历.md index 45b576e7..4beed650 100644 --- a/problems/二叉树的递归遍历.md +++ b/problems/二叉树的递归遍历.md @@ -116,19 +116,19 @@ Java: ```Java // 前序遍历·递归·LC144_二叉树的前序遍历 class Solution { - ArrayList preOrderReverse(TreeNode root) { - ArrayList result = new ArrayList(); - preOrder(root, result); + public List preorderTraversal(TreeNode root) { + List result = new ArrayList(); + preorder(root, result); return result; } - void preOrder(TreeNode root, ArrayList result) { + public void preorder(TreeNode root, List result) { if (root == null) { return; } - result.add(root.val); // 注意这一句 - preOrder(root.left, result); - preOrder(root.right, result); + result.add(root.val); + preorder(root.left, result); + preorder(root.right, result); } } // 中序遍历·递归·LC94_二叉树的中序遍历