Skip to content

Commit be5d5d0

Browse files
Merge pull request #1 from marta-liushniak/diff
array-diff-solution
2 parents da9eb8f + 5d8978a commit be5d5d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/arraydiff/Main.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package arraydiff;
22

3+
import java.util.Arrays;
4+
35
public class Main {
46
public static void main(String[] args) {
7+
System.out.println(Arrays.toString(arrayDiff(new int[]{1, 2, 2, 2, 3}, new int[]{2})));
8+
}
59

10+
public static int[] arrayDiff(int[] a, int[] b) {
11+
return Arrays
12+
.stream(a)
13+
.filter(x -> Arrays.stream(b).noneMatch(y -> y == x))
14+
.toArray();
615
}
716
}

0 commit comments

Comments
 (0)