Fetch the repository succeeded.
package LeetCode;
import java.util.ArrayList;
import java.util.HashSet;
public class LC_349 {
public static void main(String[] args) {
}
public static int[] intersection(int[] nums1, int[] nums2) {
HashSet<Integer> set1 = new HashSet<>();
HashSet<Integer> set2 = new HashSet<>();
for (int i = 0; i < nums1.length; i++) {
set1.add(nums1[i]);
}
for (int i = 0; i < nums2.length; i++) {
set2.add(nums2[i]);
}
ArrayList<Integer> sam = new ArrayList<>();
for (Integer integer : set1) {
int cont = 0;
if (set2.contains(integer)) {
sam.add(integer);
}
}
int size = sam.size();
int[] sam1 = new int[size];
for (int i = 0; i < sam1.length; i++) {
sam1[i] = sam.get(i);
}
return sam1;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。