修改0349 - 用 Java stream 代替 for loop (这样主题更明显)

This commit is contained in:
Shuo Zhang
2022-06-27 22:54:52 -04:00
parent 1ca56dd472
commit 16af63e22a

View File

@ -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();
}
}
```