JAVA_Intersection of Two Arrays_LeetCode 349


JAVA_Intersection of Two Arrays_LeetCode 349

JAVA_Intersection of Two Arrays_LeetCode 349 풀이 class Solution { public int[] intersection(int[] nums1, int[] nums2) { Set<Integer> set1 = new HashSet(); Set<Integer> set2 = new HashSet(); for(int i : nums1) set1.add(i); for(int i : nums2) set2.add(i); set1.retainAll(set2); int n = set1.size(); int[] res = new int[n]; int index = 0; for(int i : set1) res[index++] = i; return res; } } * 출처 Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get ...


#IntersectionofTwoArrays_LeetCode349 #JAVA #JAVA_IntersectionofTwoArrays #JAVA_IntersectionofTwoArrays_LeetCode349 #JAVA_LeetCode349

원문링크 : JAVA_Intersection of Two Arrays_LeetCode 349