-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathIntersection.java
More file actions
33 lines (26 loc) · 1.04 KB
/
Intersection.java
File metadata and controls
33 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
**
* QUESTION 2
* ==========
*
* Complete the function 'findIntersection' below to find the intersection of two arrays. An intersection would be
* the common elements that exists within both arrays. In this case, make sure that the elements returned are
* also unique!
*
*/
import java.util.Arrays;
public class Intersection {
static int[] firstArray = new int[]{2, 2, 4, 1};
static int[] secondArray = new int[]{1, 2, 0, 2};
public static int[] findIntersection(int[] arr1, int[] arr2) {
// TODO: [Your code here]
/**
* I assume this wants me to make the array have unique items, if thats the case I would use the
* java Set<> as it holds unique values. then find values that are common between the 2 arrays.
* If my assumption is correct an you insist in me doing it, let me know.
*/
}
public static void main(String args[]) {
int[] intersection = findIntersection(firstArray, secondArray);
System.out.println(Arrays.toString(intersection));
}
}