From fe0d0f8c5be965b69f2db0c966c2a8b7135e9f35 Mon Sep 17 00:00:00 2001 From: hbingzhi Date: Tue, 3 Jan 2023 17:46:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?232.=E4=BF=AE=E6=94=B9=E6=96=87=E5=AD=97?= =?UTF-8?q?=E5=8F=99=E8=BF=B0=E9=94=99=E8=AF=AF=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0232.用栈实现队列.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/problems/0232.用栈实现队列.md b/problems/0232.用栈实现队列.md index 4983c93a..efeb1046 100644 --- a/problems/0232.用栈实现队列.md +++ b/problems/0232.用栈实现队列.md @@ -38,7 +38,7 @@ queue.empty(); // 返回 false ## 思路 -《代码随想录》算法公开课:[栈的基本操作! | LeetCode:232.用栈实现队列](https://www.bilibili.com/video/BV1nY4y1w7VC),相信结合视频再看本篇题解,更有助于大家对链表的理解。 +《代码随想录》算法公开课:[栈的基本操作! | LeetCode:232.用栈实现队列](https://www.bilibili.com/video/BV1nY4y1w7VC),相信结合视频再看本篇题解,更有助于大家对栈和队列的理解。 这是一道模拟题,不涉及到具体算法,考察的就是对栈和队列的掌握程度。 @@ -662,3 +662,4 @@ impl MyQueue { + From 2d2babdaf0ce7ceb3f61c26c7e959ed2776bda62 Mon Sep 17 00:00:00 2001 From: hbingzhi Date: Sun, 8 Jan 2023 12:58:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?349.=E6=9C=80=E5=90=8E=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E6=B7=BB=E5=8A=A0=E5=8F=A6=E4=B8=80=E7=A7=8D?= =?UTF-8?q?=E5=86=99=E6=B3=95=EF=BC=8C=E6=9B=B4=E5=A4=9A=E4=BA=BA=E5=AE=B9?= =?UTF-8?q?=E6=98=93=E7=90=86=E8=A7=A3=E7=9C=8B=E6=87=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0349.两个数组的交集.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/problems/0349.两个数组的交集.md b/problems/0349.两个数组的交集.md index 2e98ef6f..6f5a34e7 100644 --- a/problems/0349.两个数组的交集.md +++ b/problems/0349.两个数组的交集.md @@ -137,8 +137,18 @@ class Solution { resSet.add(i); } } - //将结果几何转为数组 + + //方法1:直接将结果几何转为数组 return resSet.stream().mapToInt(x -> x).toArray(); + + //方法2:另外申请一个数组存放setRes中的元素,最后返回数组 + int[] arr = new int[setRes.size()]; + int j = 0; + for(int i : setRes){ + arr[j++] = i; + } + + return arr; } } ``` @@ -423,3 +433,4 @@ C#: +