Merge pull request #1499 from s-zhang-cs/0349

修改0349 - 用 Java stream 代替 for loop
This commit is contained in:
程序员Carl 2022-07-14 08:45:53 +08:00 committed by GitHub
commit 0b251210ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 6 deletions

View File

@ -104,13 +104,8 @@ class Solution {
resSet.add(i); resSet.add(i);
} }
} }
int[] resArr = new int[resSet.size()];
int index = 0;
//将结果几何转为数组 //将结果几何转为数组
for (int i : resSet) { return resSet.stream().mapToInt(x -> x).toArray();
resArr[index++] = i;
}
return resArr;
} }
} }
``` ```