File tree 2 files changed +49
-0
lines changed
2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -28,4 +28,16 @@ My current statistic
28
28
| [ 3Sum Closest] ( https://leetcode.com/problems/3sum-closest/#/description ) | [ Java] ( https://github.com/edyluisrey/Leetcode-Algorithms/blob/master/src/leetcode/TreeSumClosest.java ) | LeetCode Online Judge |
29
29
| [ Sort Characters By Frequency] ( https://leetcode.com/problems/sort-characters-by-frequency/#/description ) | [ Java] ( https://github.com/edyluisrey/Leetcode-Algorithms/blob/master/src/leetcode/SortCharactersByFrequency.java ) | LeetCode Online Judge |
30
30
| [ Kill Process] ( https://leetcode.com/problems/kill-process/#/description ) | [ Java] ( ) | LeetCode Online Judge |
31
+ | [ Isomorphic Strings] ( https://leetcode.com/problems/isomorphic-strings/#/description ) | [ Java] ( https://github.com/edyluisrey/Leetcode-Algorithms/blob/master/src/leetcode/IsomorphicStrings.java ) | LeetCode Online Judge |
32
+ | [ Intersection of Two Arrays] ( ) | [ Java] ( ) | LeetCode Online Judge |
33
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
34
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
35
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
36
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
37
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
38
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
39
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
40
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
41
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
42
+ | [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
31
43
| [ ] ( ) | [ Java] ( ) | LeetCode Online Judge |
Original file line number Diff line number Diff line change
1
+ package leetcode ;
2
+
3
+ import java .util .Arrays ;
4
+ import java .util .HashSet ;
5
+ import java .util .Iterator ;
6
+ import java .util .Set ;
7
+
8
+ public class IntersectionTwoArrays {
9
+
10
+ public static void main (String [] args ){
11
+ IntersectionTwoArrays test = new IntersectionTwoArrays ();
12
+ int [] res = test .intersection (new int []{1 }, new int []{1 ,1 });
13
+ System .out .println (Arrays .toString (res ));
14
+ }
15
+
16
+ public int [] intersection (int [] nums1 , int [] nums2 ) {
17
+ Set <Integer > set = new HashSet <Integer >();
18
+ for (int i =0 ; i < nums1 .length ; i ++){
19
+ set .add (nums1 [i ]);
20
+ }
21
+ Set <Integer > set2 = new HashSet <>();
22
+ for (int i =0 ; i <nums2 .length ; i ++){
23
+ if (set .contains (nums2 [i ]))
24
+ set2 .add (nums2 [i ]);
25
+ }
26
+ int [] res = new int [set2 .size ()];
27
+ int k =0 ;
28
+ Iterator <Integer > it = set2 .iterator ();
29
+ while (it .hasNext ()){
30
+ res [k ]= it .next ();
31
+ k ++;
32
+ }
33
+ return res ;
34
+ }
35
+ }
36
+
37
+
You can’t perform that action at this time.
0 commit comments