diff --git a/problems/0349.两个数组的交集.md b/problems/0349.两个数组的交集.md index 98518647..2a8b2dae 100644 --- a/problems/0349.两个数组的交集.md +++ b/problems/0349.两个数组的交集.md @@ -104,13 +104,8 @@ class Solution { resSet.add(i); } } - int[] resArr = new int[resSet.size()]; - int index = 0; //将结果几何转为数组 - for (int i : resSet) { - resArr[index++] = i; - } - return resArr; + return resSet.stream().mapToInt(x -> x).toArray(); } } ```